Skip to content

Instantly share code, notes, and snippets.

@mgirouard
Created November 1, 2010 17:03
Show Gist options
  • Save mgirouard/658507 to your computer and use it in GitHub Desktop.
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
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