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

if ($microformats)
    $whohtml='<SPAN CLASS="vcard author">'.$whohtml.'</SPAN>';

Add:

$whohtml.=' ('.qa_html($postuserid).')';

This code works great to display user ID number.  What key is required to display the users full_name instead of ID count?

1 Answer

+4 votes
by
selected by
 
Best answer

There is no key to do so. You need to get it from the DB as it is a user field.

Open the qa-include/qa-app-format.php file and try this code. Green lines are the new added ones:

if (isset($postuserid) && isset($usershtml[$postuserid])) {
    $whohtml=$usershtml[$postuserid];
    if ($microformats)
        $whohtml='<span class="vcard author">'.$whohtml.'</span>';
    $userprofile = qa_db_select_with_pending(qa_db_user_profile_selectspec($postuserid, true));
    if (isset($userprofile['name']) && !empty($userprofile['name'])) {
        $whohtml .= ' (' . qa_html($userprofile['name']) . ')';
    }
} else {
 
It's worth mentioning that it is better to write a plugin rather than adding a core hack but that will be more complex :)
by
I agree this is not ideal as future updates will overwrite this and require putting it back. I did see the ability to choose this at admin level was requested for next version so hopefully it gets updated.  

The solution worked perfectly and resolves the issue I was having.  Thanks!
by
Upper method is easy and good. However, I recommend that you inspect the performance of your site at the same time. Probably the number of queries will increase. When there is the database of your site to another server, deterioration of the performance may become remarkable. A method not to worsen performance is to change some functions of qa-include/qa-db-selects.php. However, it is difficult. Because many users hope for displaying data of qa_userprofile table (include full-name), I think that it is coped in Q2A V1.7.
by
Thanks for the heads up, will monitor performance.
...