Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+12 votes
2.2k views
in Q2A Core by

Is it possible to display Full Name instead of usernames on pages, questions, posts? I would like to display the name instead of usernames.

Thank you

Q2A version: 1.5.3
by
has there been any resolution to this?
by
This is useful question. The best way is show full name, not username.
by
I suggest that a better way is to provide a nickname field in the user profile that the user can use to override the userhandle display - without SSO, the user handle does that already but is less flexable and when SSO is employed and you don't have control over the userhandle, a nickname field that could be set by the user would be a nice feature.
by
Agreed with ScottCher. Displaying username is not optimal as the only option. Nickname is what Wordpress uses and which would be a natural sync on both platforms. It also adds another possible layer of security.
by
Instead of restricting it, wouldn't it make sense to add an option so that the admin can set which of the defined fields he/she wants to set as "displayed name"??

1 Answer

+4 votes
by
edited by

I created a simple plug-in (function override) to do this for my internal site.  The code is based on the code found on another thread which I have modified.

I think a better approach might be to change the userhandle map that links "user id" to the "handle" that's displayed throughout the application but I don't think that function can be overridden so it would have been a more involved change that I wasn't prepared to do.

I overrode qa_get_one_user_html() in the qa-app-users.php (Q2A 1.5.2) include file using an override plugin...

replacing this:

 

return strlen($handle) ? ('<A HREF="'.qa_path_html('user/'.$handle).
    '" CLASS="qa-user-link'.($microformats ? ' url nickname' : '').
    '">'.qa_html($handle).'</A>') : '';

 

with this:

 




$userprofiles = qa_db_select_with_pending(qa_db_user_profile_selectspec($handle,false));
$userdisplayhandle = $handle;
if(@$userprofiles['name'] != '')
{
    $userdisplayhandle = @$userprofiles['name'];
}
return strlen($userdisplayhandle) ? ('<A HREF="'.
    qa_path_html('user/'.$handle).'" CLASS="qa-user-link'.
    ($microformats ? ' url nickname' : '').'">'.qa_html($userdisplayhandle).
    '</A>') : '';
 
 
This approach does have its issues:

1) It won't update all locations where the username is displayed.  It does update the user list, the question list and the question pages.  It does not update the user profile / account pages (which I don't necessarily think is a bad thing, since that's where you would see your userid).

2) It will break some plugins that look for the username found in the userhandle map.  One example of this is the Badges plugin by NoahY.  Its not a bug in his code, its the way my change modifies what his code is looking for to display the badge widget.  I've fixed that issue locally - without the fix, the badge widget just doesn't display for users who's full name is displayed instead of their userhandle.

Note, I'm doing this because we implemented a custom SSO for our site and wanted to give users the flexability to change their user id (a generic alpha-numeric string in our case) to show a custom name that people can more easily recognize.

 

by
Thanks ScottCher.
by
I can confirm that it works. Thanks a lot!
by
Hi,

I am using LDAP plugin, want to display the user name instead of the handle, because the userid makes no sense while looking at the user details. I followed your answer here and need help in overriding the username with name for the User Profile and Account page also.

1) It won't update all locations where the username is displayed.  It does update the user list, the question list and the question pages.  It does not update the user profile / account pages (which I don't necessarily think is a bad thing, since that's where you would see your userid).

can you give some info on this.
Thanks.
...