I assume that you know which Wordpress interceptors you want to use. Therefore, skipping this part, it is quite easy to get the current user role.
$current_user = wp_get_current_user(); if ( !($current_user instanceof WP_User) ) return; $roles = $current_user->roles;
Now you can iterate over this array to find out if the user has a specific role.
Or you can use current_user_can to search for specific features if you just want to check if the user has a specific permission or not in the role. For example:
if (current_user_can('delete_posts')) {
villecoder
source share