So far I've only found plugins that are either obsolete or only affect which categories are displayed.

EDIT: The result should be that users can only select certain categories when they publish their post.

1 Answer 1


Try using these codes:

function themename_check_user_role( $role, $user_id = null ) {

    if ( is_numeric( $user_id ) )
    $user = get_userdata( $user_id );
        $user = wp_get_current_user();

    if ( empty( $user ) )
    return false;

    return in_array( $role, (array) $user->roles );

// example use for the current user
if ( themename_check_user_role( 'customer' )
    _e( "You've got access!", 'themename' );
    _e( "Sorry, you don't have access!", 'themename' );

Here, you are checking whether a particular user has a role or not. If a match is found, true will be returned.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.