• Resolved hakimthedream68

    (@hakimthedream68)


    I tried to bypass the limit for certain roles (administrator, editor, author) by creating my own plugin (which is the far better but a bid more complicated option than to touch functions.php file) and paste your function loggedin_bypass_roles into the corresponding plugins .php file and activated it without any problems. Problem is, that it’s not doing what it should do!
    Wordpress kicks me out as administrator when I reach the maximum (set to 1) limit. Its seems as either there is a bug in your code or the add_filter(‘loggedin_bypass’,….) hook is never activated?
    Can you kindly help, as this is a very important feature for websites with paid user logins and its administrators.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter hakimthedream68

    (@hakimthedream68)

    Ist seems as if the plugin author has last time resolved any support question about 10 months ago. I guess this plugin is dead? Can someone please post an alternative plugin to limit active logins with bypass for certain roles (eg. admin)?

    Plugin Author Joel James

    (@joelcj91)

    Hey @hakimthedream68,

    This plugin is not dead. I was busy with my full time job. Sorry for the delay.

    Can you post your custom script which you used for bypassing the login?

    If I may interject, I just implemented the filter for bypassing a role.
    It seems filter code snippet is wrong, you have a variable called $allowed_roles which is never used, I changed it to $whitelist which is the name of the variable that is returned and it works.
    Here’s the rewritten snippet:

    //bypass login limit for admin and editor
    function loggedin_bypass_roles( $prevent, $user_id ) {
    
        // Array of roles to bypass.
        $whitelist = array( 'administrator', 'editor' );
    
        $user = get_user_by( 'id', $user_id );
    
        $roles = ! empty( $user->roles ) ? $user->roles : array();
    
        return ! empty( array_intersect( $roles, $whitelist ) );
    }
    
    add_filter( 'loggedin_bypass', 'loggedin_bypass_roles', 10, 2 );
    Plugin Author Joel James

    (@joelcj91)

    Hey @calypso88,

    You are right. The variable name given in the example snippet was wrong. I’ve just updated it. Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘loggedin_bypass’ is closed to new replies.