L
L
ligisayan2016-03-14 15:29:49
PHP
ligisayan, 2016-03-14 15:29:49

How to display the user's first and last name on the screen in wordpress?

Greetings. How can I display the user's first and last name in wordpress? I use wp_get_current_user() function

$aboutuser = <a href="http://wp-kama.ru/function/wp_get_current_user">wp_get_current_user();</a>
var_dump($aboutuser);

at the output I get:
{ ["data"]=> object(stdClass)#2670 (10) { ["ID"]=> string(1) "1" ["user_login"]=> string(5) "Mboat" ["user_pass"]=> string(34) "$P$BbDsCTGVe/Xtc" ["user_nicename"]=> string(5) "mboat" ["user_email"]=> string(21) "[email protected]" ["user_url"]=> string(0) "" ["user_registered"]=> string(19) "2015-12-11 08:25:20" ["user_activation_key"]=> string(0) "" ["user_status"]=> string(1) "0" ["display_name"]=> string(5) "Mboat" }..

in which, in theory, the name and surname should be displayed like this:
$aboutuser->user_firstname;
$aboutuser->user_lastname;

but writes null
And for the get_currentuserinfo function it finds nothing at all. How to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yakov Vylegzhanin, 2016-03-14
@ligisayan

Perhaps the answer to your question is here .

global $current_user;

echo 'Username: ' . $current_user->user_login . '<br />';
echo 'User email: ' . $current_user->user_email . '<br />';
echo 'User first name: ' . $current_user->user_firstname . '<br />';
echo 'User last name: ' . $current_user->user_lastname . '<br />';
echo 'User display name: ' . $current_user->display_name . '<br />';
echo 'User ID: ' . $current_user->ID;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question