Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
696 views
in Q2A Core by
I want to show the full name of user in all post meta like question, answer, comment, private message etc.

Please help me to do this.
Q2A version: Latest
by
edited by
Thanks for your answer, I have replaced plugin codes with q2a original function.
by
@Won't Answer Pricks

Can you give me the modified post_meta_who($post, $class) function codes for showing full name.
by
edited by
I hope you already know that saving changes directly to core will not survive future upgrades. And your customized theme should be renamed as a different name (and in a different theme folder).

If you want to modify  post_meta_who function or its parent or grandparent functions, you are repeating what should be done with qa_get_one_user_html.

The code is long, and I'm not sure if it's syntacially correct. In my site, I use a custom function for this, so cannot actually test.

public function post_meta_who($post, $class)
    {
        if (isset($post['who'])) {
            $this->output('<span class="' . $class . '-who">');

            if (strlen(@$post['who']['prefix']))
                $this->output('<span class="' . $class . '-who-pad">' . $post['who']['prefix'] . '</span>');

//change to fullname if exists
            if (isset($post['who']['data'])){
$handle = $post['raw']['handle'];
$userprofiles = qa_db_select_with_pending(qa_db_user_profile_selectspec($handle,false));
if (isset($userprofiles['name'])){
$fullname = qa_html($userprofiles['name']);
$this->output('<span class="' . $class . '-who-data"><span itemprop="author" itemscope itemtype="https://schema.org/Person"><a href="../user/'.qa_html($handle).'" class="qa-user-link" itemprop="url"><span itemprop="name">'.$fullname.'</span></a></span></span></span>');
}

else {
$this->output('<span class="' . $class . '-who-data">' . $post['who']['data'] . '</span>');
}
}

//end of change to fullname
            if (isset($post['who']['title']))
                $this->output('<span class="' . $class . '-who-title">' . $post['who']['title'] . '</span>');

            // You can also use $post['level'] to get the author's privilege level (as a string)

            if (isset($post['who']['points'])) {
                $post['who']['points']['prefix'] = '(' . $post['who']['points']['prefix'];
                $post['who']['points']['suffix'] .= ')';
                $this->output_split($post['who']['points'], $class . '-who-points');
            }

            if (strlen(@$post['who']['suffix']))
                $this->output('<span class="' . $class . '-who-pad">' . $post['who']['suffix'] . '</span>');

            $this->output('</span>');
        }
    }
by
edited by
I think it can be better with direct MySQL query with userid


$userid = $post['raw']['userid'];
$userprofiles = qa_db_read_one_value(qa_db_query_sub('SELECT content FROM ^userprofile WHERE userid=$ and title ="name"', $userid),true);

Please log in or register to answer this question.

...