Support » Plugin: Prevent Concurrent Logins » Concurrent login for some users

  • How do I implement the function in your FAQ section for allowing concurrent logins for some users?

    function pcl_bypass_admins( $user_id ) {
        $user = get_user_by( 'id', absint( $user_id ) );
    
        if ( ! empty( $user->roles[0] ) && 'administrator' === $user->roles[0] ) {
            return false;
        }
    
        return true;
    }
    add_filter( 'pcl_prevent_concurrent_logins', 'pcl_bypass_admins' );

    I’m not a coder. Where specifically do I add the user id that i want to allow concurrent logins?

    https://wordpress.org/plugins/prevent-concurrent-logins/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Frankie Jarrett

    (@fjarrett)

    Hi David,

    Just as the FAQ says you need to place that block of code into your theme’s functions.php file or in an MU plugin.

    The $user_id param is supplied by the pcl_prevent_concurrent_logins filter being hooked into.

    The example code is designed to bypass any user with the Administrator role.

    Thread Starter David Jamieson

    (@dallenj)

    Ok thanks. It wasn’t clear to me that the bypass is based on roles, not on individual users.
    I understand now.

    Plugin Author Frankie Jarrett

    (@fjarrett)

    I’ve just updated the FAQ to include code examples for both bypass methods, by user ID and by user role.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Concurrent login for some users’ is closed to new replies.