Created
October 20, 2015 09:31
-
-
Save yanknudtskov/9d99a63d8bf837ac3a4e to your computer and use it in GitHub Desktop.
List custom rolenames in the WordPress Admin User List area
This file contains hidden or 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 | |
| /** | |
| * Display Custom Roles in WordPress Admin | |
| */ | |
| add_action('manage_users_custom_column', 'yanco_show_user_roles_column_content', 10, 3); | |
| function yanco_show_user_roles_column_content($value, $column_name, $user_id) { | |
| global $wp_roles; | |
| $user = get_userdata( $user_id ); | |
| $user_roles = ''; | |
| if ( 'roles' == $column_name ) { | |
| if ( !empty( $user->roles ) && is_array( $user->roles ) ) { | |
| foreach ( $user->roles as $user_role ) { | |
| foreach ( $wp_roles->role_names as $wp_role => $wp_role_name ) { | |
| if($user_role == $wp_role) { | |
| $user_roles .= $wp_role_name; | |
| } | |
| } | |
| } | |
| } | |
| return $user_roles; | |
| } | |
| return $value; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment