Skip to content

Instantly share code, notes, and snippets.

@nathaningram
Created September 5, 2017 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathaningram/620e46f3abbe8e878831aad0475529b2 to your computer and use it in GitHub Desktop.
Save nathaningram/620e46f3abbe8e878831aad0475529b2 to your computer and use it in GitHub Desktop.
Show Logged In User First Name Shortcode
// Show Logged In User First Name Shortcode
function show_loggedin_function( $atts ) {
global $current_user, $user_login;
get_currentuserinfo();
add_filter('widget_text', 'do_shortcode');
if ($user_login)
return 'Welcome ' . $current_user->first_name . '!';
else
return '<a href="' . wp_login_url() . ' ">Login</a>';
}
add_shortcode( 'show_loggedin_as', 'show_loggedin_function' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment