Last active
January 11, 2021 09:39
-
-
Save Pross/e74b518d62d5b1dbe02afff8be5de399 to your computer and use it in GitHub Desktop.
Current user role 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
<?php // ADDED FOR CODE HIGHLIGHTING | |
add_shortcode( 'current_role', function() { | |
global $wp_roles; | |
$current_user = wp_get_current_user(); | |
$role = array_shift( $current_user->roles ); | |
return isset( $wp_roles->role_names[ $role ] ) ? translate_user_role( $wp_roles->role_names[ $role ] ) : false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment