Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

bug in the faq snippet for bypassing roles

$
0
0

Replies: 0

I used the snippet in the faq and if was to be fixed

function loggedin_bypass_roles( $prevent, $user_id ) {

    // Array of roles to bypass.
    $allowed_roles = array( 'administrator', 'editor' );

    $user = get_user_by( 'id', $user_id );

    $roles = ! empty( $user->roles ) ? $user->roles : array();

    return ! empty( array_intersect( $roles, $whitelist ) );
}

// on the line up here i think you have to change $whitelist with $allowed_roles

add_filter( 'loggedin_bypass', 'loggedin_bypass_roles', 10, 2 );

Viewing all articles
Browse latest Browse all 59525

Trending Articles