Username (Nickname) vs. Real Name

Discussion forum for MOD Writers regarding MOD Development.
Locked
sokeking
Registered User
Posts: 8
Joined: Sat Jan 03, 2009 7:54 pm

Username (Nickname) vs. Real Name

Post by sokeking »

Hello everybody,
Last week i've set up my first 'own' forum using the newest version of phpbb3. Unfortunately i will have to do some modifications to fit my requests. I've already searched this forum from top to down and from bottom up... but i've found nothing answering my question.

Ok. I made two custom profile fields. One called 'name' and the other 'vorname' (sry i'm german :lol:). 'name' stands for the last name of the user, 'vorname' for the first one. When somebody registers to the forum, he has to fill out these two fields. Because every member of our forum/club whatever has an emailadress (like: "b.heinz@..." for Benjamin Heinz) it is very convinient that they can log onto the mailserver and into the forum with the same username (for example: b.heinz). But in the forum itself it is very important for the users to have a connection to the real person, they are talking to. So the real names should be displayed - don't ask me what happens, if there are two persons with the same name :shock:.
Anyway. The real name is made up by merging the first and the last name of each person. Although it is not possible to leave these fields empty, i want to implementate an isset check. If it is unset, the username (nickname) should be displayed.
I've integrated some lines into the viewtopic_body.html of my template.

Code: Select all

				<!-- IF postrow.POSTER_AVATAR -->
					<!-- IF postrow.U_POST_AUTHOR --><a href="{postrow.U_POST_AUTHOR}">{postrow.POSTER_AVATAR}</a><!-- ELSE -->{postrow.POSTER_AVATAR}<!-- ENDIF --><br />
				<!-- ENDIF -->
				<!-- IF not postrow.U_POST_AUTHOR -->
					<!-- IF postrow.PROFILE_VORNAME_VALUE != '' and postrow.PROFILE_NAME_VALUE != '' -->
						<strong><a href={postrow.U_PROFILE}><span style="color: {postrow.POST_AUTHOR_COLOUR}">{postrow.PROFILE_VORNAME_VALUE} {postrow.PROFILE_NAME_VALUE}</span></a></strong>
					<!-- ELSE -->
						<strong>{postrow.POST_AUTHOR_FULL}</strong>
					<!-- ENDIF -->
				<!-- ELSE -->
					<!-- IF postrow.PROFILE_VORNAME_VALUE != '' and postrow.PROFILE_NAME_VALUE != '' -->
						<a href={postrow.U_PROFILE}><span style="color: {postrow.POST_AUTHOR_COLOUR}">{postrow.PROFILE_VORNAME_VALUE} {postrow.PROFILE_NAME_VALUE}</span></a>
					<!-- ELSE -->
						{postrow.POST_AUTHOR_FULL}
					<!-- ENDIF -->
				<!-- ENDIF -->
But because i have to integrate these lines several times (furthermore in memberlist, ... - even though the code would be different), i was asking myself, if it is necessary to do so. Especially the isset check for both, first and last name is done each time a name is supposed to be printed. Call me sensitive but isn't it unefficient?
Is there an other way? I was thinking of extending the get_username_string and to call it with
'get_username_string('realname', ...' when i want to use the realname. But it didn't work. I weren't able to get the custom profile fields.
(I should mention, that it still should be possible for me as an admin to see the username in the profile and the ACP. That is what i thought with "when i want to use the realname" - because sometimes i want the still prefer to see the username)

I hope you guys can help me.

Thank you very much,
Benni

cuyeda
Registered User
Posts: 1
Joined: Mon Jan 05, 2009 7:37 pm

Re: Username (Nickname) vs. Real Name

Post by cuyeda »

Benni,
Good luck in getting an answer to your question. I too have come to search for this answer of using real names vs. nicknames.

sokeking
Registered User
Posts: 8
Joined: Sat Jan 03, 2009 7:54 pm

Re: Username (Nickname) vs. Real Name

Post by sokeking »

hey cuyeda,
yeah, i'm really impressed, that theres no solution for this issue because it seems to be a common request to have such an opportunity. maybe it is not possible to do that without recoding huge parts of phpbb3. but if that is the fact, i really would appreciate the mods to tell me that. *smile*

Greetings,
Benni

sokeking
Registered User
Posts: 8
Joined: Sat Jan 03, 2009 7:54 pm

Re: Username (Nickname) vs. Real Name

Post by sokeking »

*bumb*

CorniI
Registered User
Posts: 38
Joined: Tue Apr 03, 2007 1:45 pm
Location: Germany

Re: Username (Nickname) vs. Real Name

Post by CorniI »

you want to modify user_get_id_name() in includes/functions_user.php and also, to make life easier for you (*attention* this _may_ introduce bugs to your forum) just set $user->data['username'] to the one you've displayed. But beware, this is not tested and requires a bit php knowledge ;)

tvangstr0ye
Registered User
Posts: 7
Joined: Mon Apr 20, 2009 11:30 am

Re: Username (Nickname) vs. Real Name

Post by tvangstr0ye »

I'm trying to accomplish the same as sokeking, I want the custom profiles fields firstname + lastname to replace username in posts and in the "who is online" function.
I'm not particularly php savvy so the instructions given here are a little unclear to me.

Could anyone clarify what I would need to modify?

Cheers

tvangstr0ye
Registered User
Posts: 7
Joined: Mon Apr 20, 2009 11:30 am

Re: Username (Nickname) vs. Real Name

Post by tvangstr0ye »

*bump*
Anyone?

pumpkinkid
Registered User
Posts: 91
Joined: Wed Oct 31, 2007 3:36 am

Re: Username (Nickname) vs. Real Name

Post by pumpkinkid »

While I have always been "old-school" and hated going into the new "social networking" feel (Using Real Names) I can try to help you guys out...

First off... why not go straight to the database instead of using a custom field? Add two fields for First and Last name... like that every time the user_id is collected, its a matter of asking for those two fields as well...

tvangstr0ye
Registered User
Posts: 7
Joined: Mon Apr 20, 2009 11:30 am

Re: Username (Nickname) vs. Real Name

Post by tvangstr0ye »

Ok, so I found the data within "phpbb_profile_fields_data". The two fields first and lastname are pf_fornavn, and pf_etternavn. What do I need to modify to ask for those two fields instead of username?

pumpkinkid
Registered User
Posts: 91
Joined: Wed Oct 31, 2007 3:36 am

Re: Username (Nickname) vs. Real Name

Post by pumpkinkid »

Depends on where you need to import the information to.... For example, to replace the username with their real name you would have to first collect the two fields and pass it on to viewtopic_body.html...

This is untested, but you could do something like this...

In viewtopic.php Find:

Code: Select all

$postrow = array(
		'POST_AUTHOR_FULL'		=> get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
		'POST_AUTHOR_COLOUR'	=> get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
		'POST_AUTHOR'			=> get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
		'U_POST_AUTHOR'			=> get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),

		'RANK_TITLE'		=> $user_cache[$poster_id]['rank_title'],
		'RANK_IMG'			=> $user_cache[$poster_id]['rank_image'],
The above code is responsible for picking up the user's data...

Compare it to this code and see where I added the two fields...

Code: Select all

$postrow = array(
		'POST_AUTHOR_FULL'		=> get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
		'POST_AUTHOR_COLOUR'	=> get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
		'POST_AUTHOR'			=> get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
		'U_POST_AUTHOR'			=> get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),

		'POST_FORNAVN'	=> $user_cache[$poster_id]['pf_fornavn'],		
		'POST_ETTERNAVN'	=> $user_cache[$poster_id]['pf_etternavn'],
		'RANK_TITLE'		=> $user_cache[$poster_id]['rank_title'],
		'RANK_IMG'			=> $user_cache[$poster_id]['rank_image'],
Now it's just a matter of displaying the real name on the viewtopic_body.html... To do this, you are going to need to find exactly where the username is being placed on your theme... I have so many modified themes, the only reference code I am sure you will have is:

Code: Select all

{postrow.POSTER_AVATAR}
Find that code in viewtopic_body.html and try to find the html code for where you want to place the real name and add this:

Code: Select all

{postrow.POST_FORNAVN} {postrow.POST_ETTERNAVN}
Like I said, It's not tested, but it's what I would try first... this in no way changes the user's need to log in with their username and it does not allow you to search the user by real name.

If you need any more help understanding this, let me know... I am not feeling to well at the moment and I am under severe lack of sleep, but I will be more than happy to explain myself if needed.

tvangstr0ye
Registered User
Posts: 7
Joined: Mon Apr 20, 2009 11:30 am

Re: Username (Nickname) vs. Real Name

Post by tvangstr0ye »

First thing first, thanks alot for helping out! :D

Ok, bear with me here..
I got as far as to adding

Code: Select all

{postrow.POST_FORNAVN} {postrow.POST_ETTERNAVN}
Im guessing its somewhere in here? Im using the default theme.

Code: Select all

<!-- IF postrow.POSTER_AVATAR -->
<!-- IF postrow.U_POST_AUTHOR --><a href="{postrow.U_POST_AUTHOR}">{postrow.POSTER_AVATAR}</a><!-- ELSE -->{postrow.POSTER_AVATAR}<!-- ENDIF --><br /><!-- ENDIF -->
<!-- IF not postrow.U_POST_AUTHOR --><strong>{postrow.POST_AUTHOR_FULL}</strong><!-- ELSE -->{postrow.POST_AUTHOR_FULL}<!-- ENDIF --></dt>

pumpkinkid
Registered User
Posts: 91
Joined: Wed Oct 31, 2007 3:36 am

Re: Username (Nickname) vs. Real Name

Post by pumpkinkid »

Well close... but my directions towards that part were not so clear...

Code: Select all

<!-- IF postrow.POSTER_AVATAR -->
Basically that is as close to plain english as phpBB gets... "IF Avatar" or in other words, if the user has an avatar... so while placing the code there would work (but may not look very good) this will only work if they have an avatar image...

If I were you, I'd do it after:

Code: Select all

<!-- IF not postrow.U_POST_AUTHOR --><strong>{postrow.POST_AUTHOR_FULL}</strong><!-- ELSE -->{postrow.POST_AUTHOR_FULL}<!-- ENDIF --><br />{postrow.POST_FORNAVN} {postrow.POST_ETTERNAVN}<br /></dt>
Try it and see if you like it.

tvangstr0ye
Registered User
Posts: 7
Joined: Mon Apr 20, 2009 11:30 am

Re: Username (Nickname) vs. Real Name

Post by tvangstr0ye »

Ok, so once I implemented the code, it didn't output anything besides the <br>, I figured out that the id to get the data in viewtopic.php was wrong, I changed it and got it working. The output was ok, I'm gonna tinker with it a bit, see if I can't find a decent spot for it!
I was wondering about making the full name link to the user profile, and removing the username entry from posts altogether.

Thanks again for your patience =)

pumpkinkid
Registered User
Posts: 91
Joined: Wed Oct 31, 2007 3:36 am

Re: Username (Nickname) vs. Real Name

Post by pumpkinkid »

No problem, however, I would not remove the username, simply because phpBB is still using it to allow other users to send PM's to the correct user...

If you wish to do that, you would need to make sure that your members have a way to figure out who is who.

User avatar
betamax
Registered User
Posts: 2
Joined: Wed Apr 29, 2009 12:39 pm
Location: Prato, Italy

Re: Username (Nickname) vs. Real Name

Post by betamax »

Hi to everyone!
I have followed this topic with interest because I need too to display the "Real name" instead of the nick inside the forum.
Thank you to your suggestions I have already get the forum to show the {PROFILE_REALNAME_VALUE} inside the viewtopic_body.html but I can't get it to work inside the viewforum_body.html instead of
{topicrow.TOPIC_AUTHOR_FULL}
and
{topicrow.LAST_POST_AUTHOR_FULL}

Can you help me?

Thank you in advance for your support :)

Locked

Return to “[3.0.x] MOD Writers Discussion”