ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How can I display the {username} in the Forum Module templates?

June 17, 2009 7:11pm

Subscribe [2]
  • #1 / Jun 17, 2009 7:11pm

    sherrills

    26 posts

    I’m in the process of editing the Forum module - adding my original site header to the forum.. so that it looks integrated into the site.  I noticed that the “username” tag doesn’t work - (“screen_name” on the other hand does) - anyway, how can I display the username within the forum via the forum templates? 

    Also, if there is a list out there of all forum tags, that would be very helpful.

  • #2 / Jun 17, 2009 10:26pm

    OutofControl

    164 posts

    It would appear that some parts of the forum templates allow {username} and some parts don’t, Username Form Row under Member Profile templates for example. Unless you hack the core module, you might be out of luck in getting the username.

    It is a wee bit safer to display the screen_name and keep the username secret, as that makes it one more thing for a script kiddy figure out.

    As for a list of forum tags, I too have been looking for that.

  • #3 / Jun 17, 2009 10:37pm

    sherrills

    26 posts

    @plattapuss - thanks for the reply

    well, i’m not opposed to hacking into the core module… but since it’s just a php file.. i’m not sure what i’d need to do to display a username - any ideas?  basically… i’m trying to use my regular site header (which has the ability to sign up / login… etc) and it also displays the username (which is a hyperlink to the solspace user module) - just have no clue how to get these dynamic links actually working.

    if anyone out there has any ideas i’d love to hear them

  • #4 / Jun 18, 2009 7:22am

    OutofControl

    164 posts

    @sherrills,

    I took a look and it seems easy enough to get the username to display. Please note that there maybe a much better way of doing this that doesn’t involve hacking the forum core. Since I have been burned at upgrade time by hacking the core, I don’t recommend it.

    However, this is what worked for me:

    1 - Open /system/modules/forum/mod.forum.php in your favourite editor
    2 - Around line 1231 you will find this line:
    ‘screen_name’                  => $this->_convert_special_chars($SESS->userdata(‘screen_name’)),
    3 - Immediately below it, add this line:
    ‘username’ => $this->_convert_special_chars($SESS->userdata(‘username’)),
    4 - Save the file, and start using {username} in your template.

    Hopefully this works for you.

  • #5 / Jun 18, 2009 6:29pm

    sherrills

    26 posts

    Awesome!  Thanks Lab Assistant - you tha man (or woman) 😊  that worked great.

    I see what you mean about updates being a pain though - i’ll just have to remember to remod that file each time.

  • #6 / Jun 18, 2009 6:39pm

    OutofControl

    164 posts

    Anytime! Let me know if you notice any strangeness resulting from this change.

    Me da man 😉

  • #7 / Jun 20, 2009 11:39pm

    sherrills

    26 posts

    Lab Assistant, Sir 😉

    One more question you may or may not be able to answer.  Currently, when I link to user profiles.. I use the “username” as the last segment - not the member ID.  I’m trying to get all hyperlinks to profiles that happen when users post go to the solspace user module page… as opposed to the actual forum profile page.  The above code you provided works great for allowing a user to go in and edit their own profile.. but I’m trying to figure out how to display other peoples profiles when clicking on their username in the forum.  I realize that I can also mod the following line…

    function _profile_path($id)
           {
            global $FNS;
            return $FNS->create_url('members/profile/').$id.'/';
           }

    but i’m not really sure what I should use instead of .$id - any thoughts?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases