Created
November 1, 2010 17:03
-
-
Save mgirouard/658507 to your computer and use it in GitHub Desktop.
A quick shortcode to get a user's username injected into the page
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
add_shortcode('mg_username', 'mg_username_shortcode'); | |
function mg_username_shortcode($args) { | |
$user = wp_get_current_user(); | |
if ($user && !empty($user->user_login)) { | |
return $user->user_login; | |
} | |
else { | |
return ''; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment