WordPress Snippets at WPcustoms

Login Logout Welcome message

Uses WordPress functions and queries to pull user information with wp_get_current_user. Display the login/logout/register links based on conditional tag is_user_logged_in


/**
 * Snippet Name: Login Logout Welcome message
 * Snippet URL: http://www.wpcustoms.net/snippets/login-logout-welcome-message/
 */
   if (is_user_logged_in()) {
    // our user is logged in:
      $user = wp_get_current_user();
      echo 'Welcome back '. $user->display_name .'';
   } // if not we show different links to him
   else {
      echo 'Please '. wp_loginout() .' or  Register';
    }