Skip to content

Instantly share code, notes, and snippets.

@AlKov
Last active October 6, 2017 11:22
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 AlKov/9c9b4c46b1c4d416619b0b07febfbfb3 to your computer and use it in GitHub Desktop.
Save AlKov/9c9b4c46b1c4d416619b0b07febfbfb3 to your computer and use it in GitHub Desktop.
// check for function with the same name
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! function_exists( 'alex_vitorials_get_user_unique_name' ) ) {
function alex_vitorials_get_user_unique_name(){
if ( ! is_user_logged_in() ) {
return;
}
else {
$user = wp_get_current_user();
$avatar = get_avatar( $user->ID, 40 );
$user_nicename = '<span>';
$user_nicename .= get_userdata( $user->ID )->user_nicename;
$user_nicename .= '</span>';
return $avatar . $user_nicename;
}
}
add_shortcode( 'user-ID', 'alex_vitorials_get_user_unique_name' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment