0

I want to make login / logout function inside my header to display when the user is logged in Logged in as,{user name} where {user name} should be wrapped inside an anchor tag with a custom permalink inside the href attribute.

I've found this function <?php wp_loginout( $redirect, $echo ); ?> but I do not know if it's possible to modify this function to do what I need.

Does anyone have any suggestions on how can I do this ? Thank you !

1

You might be looking for a logged in conditional. From the WP Codex, you might be able to try in your theme (untested):

<?php
if ( is_user_logged_in() ) {
    get_currentuserinfo();
    echo 'Logged in as ' . $current_user->user_firstname;
}
?>

EDIT

After consulting the WP Codex on the topic, I was able to display my user's identity using the following:

if ( is_user_logged_in() ) {
    global $user_identity;
    get_currentuserinfo();  
    echo 'Logged in as ' . $user_identity;
}
| improve this answer | |
  • I've tried it but it doesn't display, the user name, just "Logged in as, " – agis Feb 6 '14 at 12:55
  • I updated the answer with a tested solution. Hope that helps. – NW Tech Feb 6 '14 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.