Created
December 25, 2020 11:18
-
-
Save thecodepoetry/40ab38d3e242c3c34e320ac1c5c37916 to your computer and use it in GitHub Desktop.
Display logged user name shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dt_display_username_func( $atts ){ | |
if(is_user_logged_in()) { | |
global $current_user; | |
return 'Welcome: ' . $current_user->display_name; | |
} | |
else return; | |
} | |
add_shortcode( 'username', 'dt_display_username_func' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please try this code in your child theme fucntions.php
Then insert shortcode [username] to display the user name.