MyBB Community Forums

Full Version: Display name plugin.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I would like to have my forums display a "display name" instead of the "user name" for all areas where username is currently displayed.  After extensive searching, the only solution/plugin I could find that accomplishes this is here:
http://mybbhacks.zingaburga.com/showthread.php?tid=259

This plugin hasn't been updated in quite some time and is, sadly, not compatible with v1.8.  It also breaks login capability if I edit the plugin to claim 1.8 compatibility.

My thought is that myBB has support for additional user fields and what I'd like is to replace all instances if username display with an arbitrary additional user field.  I was actually surprised that there isn't some sort of built in way to do this since I'd think that it would be a fairly commonly requested items. It also seems to not be doable with a simple theming code change as the user lists, etc. seem to be API generated variables (I may be wrong about this since I'm still learning the system so if it is possible let me know)

This is probably a good candidate for a simple plugin that I would be willing to write if someone with more "under the hood" knowledge could point me right direction for how myBB comes up with the displayed username and how to override this to instead display the contents of a specified additional user field.

Thanks in advance for any advice.

P.S. I couldn't really find a suitable place to start this thread so please move it if I've posted in the wrong spot.
I'm moving this to Plugin Development because that is where you can ask questions pertaining to creating plugins.

Unfortunately it is not as simple as you think it will be. You will need to use quite a number of hooks to achieve this. If you do not mind adding database queries, you could edit the format_username function in the /inc/functions.php file so it queries the mybb_users table with the name provided. You would then be able to pull a custom field from it and use that in the function.
Thanks for your quick reply

I assume you mean edit the format_name function. Editing the core file would work but then my changes would be overwritten whenever I install a patch unless there's a way to completely override this function from within a plugin (based on my searches the answer to that is probably no). I guess I can just investigate what hooks I can use accomplish a similar result.
I believe the Plugin Library contains a function where you can manage core edits.
Yah I found that but it's not updated for 1.8 either. I guess I'll just manually maintain my edits until the plugins catch up with the new version.
(2014-10-23, 11:04 AM)dragonexpert Wrote: [ -> ]you could edit the format_username function in the /inc/functions.php file so it queries the mybb_users table with the name provided. You would then be able to pull a custom field from it and use that in the function.
The problem with this is that quoting, sending PMs etc, would still use the login name instead of the display name, which could really confuse people.
Patching the actual login system is the simplest and most logical approach IMO.
Well my current board doesn't use PMs and I don't plan on enabling that functionality when we switch so that's not an issue to me. Quoting may be an issue (I haven't tested it yet) but I added code to both format_name and build_profile_link which seems to take care of most cases.

This really isn't a deal breaker and I've solved the "problem" mostly. I'm switching to myBB since it's being actively developed and kills quite a few annoyances that I have with my current software. I guess I really should just ask for display name functionality be added in a future version.