/** * Gets WordPress user role. * * @see: https://core.trac.wordpress.org/ticket/22624 * @see: https://wordpress.stackexchange.com/questions/131814/if-the-current-user-is-an-administrator-or-editor/324768#324768 */ if ( ! function_exists( 'get_user_role' ): function get_user_role( $user_id = 0 ) { $user = ( $user_id ) ? get_userdata( $user_id ) : wp_get_current_user(); return current( $user->roles ); } endif;
Get user role
This post brought to you by RocketGeek, ButlerBlog, and the following: