Whitelist user roles

When using the wp_login integration you might find yourself locked out even as admin or editor. To avoid this you might want to add a user role based whitelist.

// Whitelist user roles
add_filter("is_within_session_limit", "whitelist_roles", 99, 2);
function whitelist_roles(bool $within, WP_User $user) {
    $allowed_roles = array( 'editor', 'administrator', 'author' );
    if (array_intersect( $allowed_roles, $user->roles )) {
        return true;
    return $within;

Leave a Reply

Your email address will not be published. Required fields are marked *