We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

How to use "username" for forum posts and "real name" for everything else? | Forum

Huy
Huy Oct 20 '13
Hi. I would like my members to post to the forum using their usernames, while using their real names for groups, blogs, events, etc. What files would I have to modify, specifically? I've been looking through the files, and I'm not really sure where it is. Also, specific code answers are also nice. Thanks!
Alia Team
Alia Oct 21 '13
Topic was moved from Bug reports and troubleshooting.
dave Leader
dave Oct 21 '13

That will be a bit of a challenge because the function for that has already set that value for the whole script by the time the script has loaded. 

 

My original thought was to just change the forum code since that is the easiest way and have it show the usernames and leave the rest of them set as is, so basically the site would be set to use real names in admin,  but when it loads the forum it would grab its own value and use username.   Well as i said that was my original thought because i assumed that the function itself was inside the forum, but its not its in the base.

 

What that means is that this value has already been set when the script first loads, as you can see in ow_system_plugins/base/bol/user_service.php line 163

 

 /**
     * Returns display name for provided user id.
     *
     * @param integer $userId
     * @return string
     */
    public function getDisplayName( $userId )
    {
        $questionName = OW::getConfig()->getValue('base', 'display_name_question');

        $questionValue = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array($questionName));

        $displayName = isset($questionValue[$userId])
            ? ( isset($questionValue[$userId][$questionName]) ? $questionValue[$userId][$questionName] : '' )
            : OW::getLanguage()->text('base', 'deleted_user');

        return strip_tags($displayName);
    }

so you have three choices,

 

1. you can leave this alone and write your own function for just the forum and put it inside of  the ow_plugins/forum/ init.php or controllers/topic.php  im not sure which one yet

2. or you can modify this to isolate the setting just for the forum, so that if this function gets a call from the forum it will set the other value.

3. or you can add a new function and set it to what you want and add it here, and then call that function instead of this fuction from the forum topic.php

 

 

remember any changes you make, you need to make notes on there so when an update comes out you can put them back.  

 

Hope this helps..

The Forum post is edited by dave Oct 21 '13
dave Leader
dave Oct 21 '13

This seems like it will work  (untested)

 

you can put this right AFTER the other function above in ow_system_plugins/base/bol/user_service.php line 163

 

// new special mod to show username instead of realname on forums

    /**
      * Returns username just for the forum
      *
      * @param integer $userId
      * @return string
      */
     public function get_forumDisplayName( $userId )
     {
         $questionName = "username";

        $questionValue = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array($questionName));

        $displayName = isset($questionValue[$userId])
            ? ( isset($questionValue[$userId][$questionName]) ? $questionValue[$userId][$questionName] : '' )
            : OW::getLanguage()->text('base', 'deleted_user');

        return strip_tags($displayName);
     }//close function

// end special mod

 

 

 

and then in ow_plugins/forum/init.php  line 582 which is this

 

$userName = BOL_UserService::getInstance()->getDisplayName($userId);

 

Change it to this:

 

$userName = BOL_UserService::getInstance()->get_forumDisplayName($userId);

 

So your just calling your new function instead of the old one...

 

Hope that helps.. .
 

 

The Forum post is edited by dave Oct 21 '13
Huy
Huy Oct 21 '13
Thanks, Dave! I truly appreciate your help. I will try this out over the weekend.
Huy
Huy Oct 25 '13
I tried it and it does not work. I think we have to change "function forum_add_post( OW_Event $e)" in  "ow_plugins/forum/init.php" on line 268? But I'm not sure what to change.
dave Leader
dave Oct 25 '13

no regardless how it is added or what data is in the forum when it posts, it pulls the "how to display the name" after that... so let me do some testing and see where i went wrong.

 

ill be in touch ;)

dave Leader
dave Oct 25 '13

well i went thru and i found another function in the base bol thats called getDisplayNamesForList  (its right under my original one)  and several of the forum files use it..

 

so i went thru and i did the changes just like i did the other one, and it did not change a thing, so then i referred to the html to make sure it was not set there and it is not.

 

So i do apologize, but i cant seem to figure out how to do this either..   You are more than welcome to contact and official developer to see if they can work up a plugin for you, but understand this is a very very rare if never request. That means they may never sell another one so the chance of them doing it is very slim.

 

Question for you,   the name you decide in the admin panel setting is how eveyone will know them, is there a reason you want to display a different name just on the forum.  Doing that will confuse people because they will see one name on the forum and another everywhere else.

 

Plus the reason we give the option in admin is because many people dont want their username(the name the log on with) available to the public for security reasons..  Remember if you do this you will need to post this in your TOS so they agree to it.

 

Sorry i could not help more with this.. Im really not sure why its not working..

The Forum post is edited by dave Oct 25 '13