Skip to main content
Login Join
Snippet · PHP

Check Current User Role

Shared by Mukesh Gujjar · July 6, 2026

12 views
Back to Snippets

Check current user role

function get_current_user_role($role = '') {
   $user = wp_get_current_user();
   return in_array($role, (array) $user->roles, true);
}

Usage

if (is_user_logged_in() && get_current_user_role('administrator')) {}
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments