• Resolved kycam25

    (@kycam25)


    Hello @joelcj91,

    We are currently building a membership site using Memberpress. There will be different membership tiers:

    • Free Trial (limit to 1 login per device)
    • Monthly subscription (limit to 1 login per device)
    • Annual subscription (bypass to allow max of 4 logins on multiple devices)

    From what I’ve read thus far, the “limit login” bypass in the function.php pertains to user “roles” – is there a way to do this for Memberpress Membership types as well?

    Thank you in advance for your insights!

    • This topic was modified 4 years, 5 months ago by kycam25.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Joel James

    (@joelcj91)

    Hey @kycam25,

    Yes, with some custom code you can integrate with your memberships. You can use the loggedin_reached_limit filter for that.

    
    add_filter( 'loggedin_reached_limit', 'custom_loggedin_limit_check', 10, 3 );
    
    function custom_loggedin_limit_check( $reached, $user_id, $count ) {
        // Using the $user_id, check the user's membership level
        // and check if the $count is reached as per the membership.
        // If reached, return true, else return false.
    
        return $reached;
    }
    
    • This reply was modified 4 years, 5 months ago by Joel James.
    Thread Starter kycam25

    (@kycam25)

    Thank you very much, @joelcj91 ! Will test that solution out!

    Hello @joelcj91,

    We are currently building a membership site using Memberpress. There will be different membership tiers:

    Premium (limit to 2 login per device) Standard (1 login per device) Basic (1 login per device).
    Monthly subscription based website.

    I have tried implementing the code you provided above, yet i am still having some issues. Could you provide some code that would help me with my specific situation? i have the code from the previous message in my functions.php section in my theme editor, so if it is a small adjustment i could fix it.

    Thank you in advance for your insights!

    abjardim

    (@abjardim)

    Hi @kycam25,

    did the solution work for you?

    I implemented the code, and it causes an error on the website when I try to log in.
    Not sure what I am doing wrong… would appreciate any help!

    add_filter( 'loggedin_reached_limit', 'custom_loggedin_limit_check', 10, 3 );
    
    function custom_loggedin_limit_check( $reached, $user_id, $count ) {
        // Using the $user_id, check the user's membership level
        // and check if the $count is reached as per the membership.
        // If reached, return true, else return false.
    
        $limits = [
            166 => 1,
            1131 => 1,
            1132 => 3,
        ];
    
        $member = pms_get_member( $user_id );
        $member_plan = $member['subscriptions'][0]['subscription_plan_id'];
    
        if ( $count > $limits[$member_plan] ) 
        {
            $reached = true;
        }
        else
        {
            $reached = false;
        }
    
        return $reached;
    }

    I also just tried writing “if ( $count > 1 )” just to test if the mistake was with the memberships plugin, but it also doesn’t work.

    Thank you!

    mbuccaneer

    (@mbuccaneer)

    Did anyone find a way to make this work?

    Different limits for different user roles?

    Plugin Author Joel James

    (@joelcj91)

    Hey @mbuccaneer,

    Did you try using loggedin_reached_limit filter? It should work.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Bypass for Memberpress “Memberships”’ is closed to new replies.