M
M
McKlay2018-06-14 11:39:32
User Content
McKlay, 2018-06-14 11:39:32

Output first and last name and insert on the site?

Hello!
There is a site , specifically this search page. It was made on the classipress template and plus an addition to it advanced custom fields for ClassiPress was added. I want to display the first and last name (as on the site), but for some reason it displays the name that I indicated for myself, for example, from the administrator. Some announcements were added by other nicknames and, accordingly, by the first and last names. But everywhere displays mine.
The request is made like this <?php echo 'Vendor: ' . $current_user->user_firstname ,' ', $current_user->user_lastname ."\n"; ?>
There is such a cant, when you enter the first and last name, the site crashes. Doesn't want to keep. Maybe it's a site jamb, maybe a plugin. What is the alternative way to withdraw?
Tables in two are5b2228ca26bab149521885.png
I must say right away that in the wp_cp_ad_* tables there is no information about the full name

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Kozlov, 2018-06-16
@trampick

Hello. I have never used the classipress theme. But I see an error in
You will see your username in all entries, and only when you are logged in. In general, there are a lot of errors in this line. Commas instead of dots. It is not clear whether you have previously received the $current_user object somewhere.
If necessary, then you need to get the author of the post (or whatever post_type you have). And to receive fields necessary for it. For example, you can

global $post;
$post_author_id=$post->post_author;
echo 'Продавец: '.get_the_author_meta('first_name',$post_author_id).' '.get_the_author_meta('last_name',$post_author_id);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question