MyBB Community Forums

Full Version: Customized nickname instead of username
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi. For my forum i need every displayed username change to nickname, that each user enters in his/her profile. Yesterday i was trying to make this, but i discovered, that's is nearly impossible to do this without modificating original mybb code. I got covered most of the places, but some doesn't have right hook to use.

So i'm wondering if there is some other way how to do this. First idea is hook to the 'pre_output_page' and change every link leading to member profile. My regular expression catches only plain links, but if there is customized format, it's not working. I have this:


Can someone help me to extends this, so i can cover every link ? I guess i don't need extract that format, because i got uid so i can get original format.

Second idea is modication of build_profile_link function, where i can put hook to use. I was wondering if development team can put hook there for future versions, so i can upgrade forum without breaking my funcionality.

If you have any other ideas how to archive this, please tell me. Sorry for my english...
So I take it that you're trying to capture all links to a user's profile and do something about it? -That's what your code is trying to do, from what I can tell.

Your description is a little different - you're saying that you want to change the displayed username?
Hi, thanks for reply. Yes, i'm trying change displayed nickname through capturing links and changing them using preg_replace_callback. It's only suitable way o found without modifying mybb. But my regular expression cannot capture links with extra formatting of nick
<a href="member.php?action=profile&uid=1"><span style="color:green">Fredy</span></a>

Ok, nevermind. I must be sleepy yesterday or what, because that regular expression is today working Smile So problem solved.
Hmm, but if you're trying to match links, it won't replace usernames without links, or with custom formatting...

If you just want to have a system where people have separate display and login names, I'd take a different approach.
Well, it seems so far that it is almost everywhere. In quoting post there is real username, i hope this can be changed through some hook.

What different approach you would take please ? As i said, there isn't enough hooks to cover whole mybb without modifying original code. One way could be creating array in cache with pair username->nickname a replacing it in output, but i'm afraid of losing performance, because number of users will be big.
Take a look at this post:
There's a few issues with it, however, you can use the idea there. (also, note, that's for MyBB 1.2)

Hope that helps.