Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
655 views
in Q2A Core by
I've got my Q2A install hooked up to WP, such that when a user asks a question the username of that person appears under the question. So to say, if the user has the following credentials under WP:

Username: j.doe

First Name: John

Last Name: Doe

It was say that "answered 5 days ago by j.doe"

The way I see it, there should be something somewhere that's pulling a variable from the WP database to display j.doe. With that in mind, would it be possible to display "John Doe" instead? Where should I look?
Q2A version: 1.4.3

2 Answers

+1 vote
by
edited by

If you open up qa-theme-base.php and navigate to the post_meta_who function. If you then replace the if block starting if (isset($post['who']['data'])) with the following code, it should use the wordpress display name for everything except edits, as edits appear to get the username a different way, which I am currently searching for. If anyone knows where this data comes from comment and I'll update the answer and look into turning this into a plugin

 

   if (isset($post['who']['data']))
                                  if (isset($post['raw']['ouserid']))
                                        {
                                              $user_info = get_userdata($post['raw']['ouserid']);
                                        }
                                        else
                                        {
                                            $user_info = get_userdata($post['raw']['userid']);
                                        }
                                        $display_name = $user_info->display_name;
                                        $user_login = $user_info->user_login;
                                        $this->output('<SPAN CLASS="'.$class.'-who-data"><a href=/user/'.$user_login.'>'.$display_name.'</a></SPAN>');

                                if (isset($post['who']['title']))
                                        $this->output('<SPAN CLASS="'.$class.'-who-title">'.$post['who']['title'].'</SPAN>');

 

Edit:

 

I have now created a plugin to provide user display names for questions, answers comments and edits, available from here http://wiki.question2answer.org/doku.php/plugins/wordpressname

Next update will replace usernames on profile pages with display names

 

by
using this code, if you check out the buddypress plugin layer file, you can see several places where it can be used to substitute the username.
0 votes
by

In qa-include/qa-external-users-wp.php, I changed all instances of “user_nicename” to “display_name”.  That seems to be working for me so far (including edits and user profile pages).

...