I have a plugin that outputs username after login, I want it to display first name instead. Here is the code that does it.
global $userdata,$user_identity;
get_currentuserinfo();
if ($userdata->ID>0) {
// User is logged in
echo '<div class="login">' . $before_widget . $before_title . "Welcome ".$user_identity . $after_title . '</div>';
echo '
<ul class="login-links">
<li><a href="'.get_bloginfo('wpurl').'/wp-login.php?action=logout&redirect_to=http://'.$_SERVER["SERVER_NAME"].$_SERVER['REQUEST_URI'].'">Logout</a></li>
<li><a href="'.get_bloginfo('wpurl').'/wp-admin">Dashboard</a></li>
<li><a href="'.get_bloginfo('wpurl').'/wp-admin/profile.php">Profile</a></li>
</ul>
';
} else {
// User is NOT logged in!!!
echo $before_widget . $before_title . '<div class="login">Welcome Guest, <a href="'.get_bloginfo('wpurl').'/wp-admin">Login</a></div>' . $after_title;
$user_identity is what outputs that username
I searched through wordpress forums and someone said I have to add $current_user->first_name
to the code.
The question is, where and how do I add it? I assume I would need to add it to this line global $userdata,$user_identity;
But how do I properly syntax that?
I tried doing this but getting syntax errors global $userdata,$user_identity = $current_user->first_name;
Your help is highly appreciated.