• Hi
    I used the code for bypassing the limit for some users. I used user_ids from woocommerce like this:
    $allowed_users = array( 40, 56 );
    but the limit for these users still exists. I tested the code for roles and it worked. Is there any problem in my job?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Joel James

    (@joelcj91)

    Hey @ehsan3423,

    Could you please share you custom code here?

    Thread Starter ehsan3423

    (@ehsan3423)

    function loggedin_bypass_users( $bypass, $user_id ) {
    // Enter the user IDs to bypass.
    $allowed_users = array( 30, 44 );

    return in_array( $user_id, $allowed_users );
    }

    add_filter( ‘loggedin_bypass’, ‘loggedin_bypass_users’, 10, 2 );

    Plugin Author Joel James

    (@joelcj91)

    Hey @ehsan3423,

    Could you please check if the user IDs are valid? The code seems ok.

    Hello,

    I am experiencing a similar issue.
    Admins are being blocked from logging in as well as the other role type mentioned below.

    Here is my code:

    function loggedin_bypass_roles( $prevent, $user_id ) {
        // Array of roles to bypass.
        $allowed_roles = array( 'administrator' );
        $allowed_roles = array( 'ET Support' );
    
        $user = get_user_by( 'id', $user_id );
    
        $roles = ! empty( $user->roles ) ? $user->roles : array();
    
        $bypassed = array_intersect( $roles, $allowed_roles );
    
        return ! empty( $bypassed );
    }
    
    add_filter( 'loggedin_bypass', 'loggedin_bypass_roles', 10, 2 );

    May you kindly advise, please?
    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘code for bypassing limit for certain users not work’ is closed to new replies.