Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Show Real Name in forum_last_poster

Quote Reply
Show Real Name in forum_last_poster
I am trying to figure out how to get the forum_last_poster field to display user_real_name as opposed to user_name.

I am setting up a small forum with a limited number of users (approx 400) The forum is a closed and is for an aircraft restoration organization that I belong to and any future members will be added by the admin (me).

As such I would rather use Real Names as opposed to Usernames wherever possible throughout the entire forum. I see that a lot of these tags can simply be replaced in the templates, but there are a one or two causing me a bit of a headache Unsure

One of these being the forum_last_poster column which I assume would be updated with the current_user_name when a post is made to that forum. In which case it makes sense that I should be able to modify it so that it is updated with the user_real_name instead. Please tell me if I am on the wrong track here.

If this is in fact correct, can someone point me to where I might be able to find the code that does in fact update the forum_last_poster field, as I am not having much luck in locating it.

I would really appreciate any help you guys might be able to give me on this

Regards
Mark
Quote Reply
Re: [marker] Show Real Name in forum_last_poster In reply to
I'm afraid it isn't all that easy to change it in the code, and the changes could be overwritten on an upgrade. However, I have an alternative suggestion that should work just as well. Create a global (under Templates -> Globals) called 'username_to_real_name' and give it the following value:

Code:
sub {
my $username = shift;
my $real_name = $DB->table('User')->select('user_real_name' => { user_username => $username })->fetchrow;
return $real_name || $username;
}

Then in any templates where you want to display the real name instead of the username, simply change <%tag_name%> to <%username_to_real_name($tag_name)%>. Of course, 'tag_name' depends on where you use it; it might be 'user_username', 'forum_last_poster', 'post_username', etc. Additionally, the code above uses the username if the user doesn't exist, or if the user doesn't have something set for user_real_name.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Show Real Name in forum_last_poster In reply to
Hi Jason,

thanks for that... you are right of course, that would be the easier way to do it, and as you say it wouldnt be an issue where updates are concerned.

Thanks for pointing it out to me, it's much appreciated mate

Mark