Support » Plugin: Membership 2 » Provide User Access To Guest Membership Only Once

  • Resolved Sameer

    (@sameernxb)


    Hi,

    We have been using the membership 2 plugin and it is working fine. The problem we are facing that is how we can restrict the user to access guest membership only once. Suppose if user has signed up for Guest membership and after membership gets expired the user is not able to signed up again for Guest membership. I was checking there are many hooks of membership 2 plugin which i really like. Can you point some specific hook which can do the workaround since trial period should be once it shouldn’t be like customer keep signing for guest membership again and again. I don’t know if there is any option for that or not. I have one more question but i think this is more important as it is affecting us. Looking forward to your response.

    Best Regards,

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Dimitris – WPMU DEV Support

    (@wpmudev-support6)

    Hello @sameernxb

    I feel a bit lost here, as Guest Membership is used to – and I quote:

    Make your content available only to Guests (logged-out users).

    Could you please elaborate a bit more on the setup you have? 🙂

    Warm regards,
    Dimitris

    Hi Dimitris,

    Current Workflow

    I will try again to elaborate, currently on our site users get register and have guest membership by default. This is a trial period of 15 days. Inside user dashboard we are using membership list shortcode which displays all available memberships including paid one to which user can upgrade at any time so currently we have two membership plans one is Guest and second plan is Exclusive.

    Now suppose i have guest membership and if my trial period gets over then the workflow is like that i am still able to access my account and other pages which are not protected and it only restrict access to content which is part of the Exclusive membership. So all good here.

    Issue

    The problem comes when i am logged into my account and can access the free content and then suppose i want to upgrade my membership if i see the available list of memberships it also shows Guest membership as well along with the Exclusive membership so that is what we do not want since i have already used guest membership once so there should be any workaround via which i am not allowed to use the guest membership again and should be removed otherwise customers will keep using the guest membership and will not plan to upgrade.

    I hope this will clarify things. Looking forward to your response.

    Best Regards,

    Plugin Support Adam – WPMU DEV Support

    (@wpmudev-support8)

    Hey @sameernxb,

    Hope you’re well.

    I am assuming while you are saying “Guest membership” you are not referring membership type, only your membership name is “Guest”. There is no option something like that for the current version.

    And I am afraid I don’t think there is an easy way to do that with just some couple of lines coding. You can try “user_register” hook and assign custom user meta to the users. And every login with “wp_login” hook you can check user is expired or not.

    But if just adding a trial period to actual memberships is enough for you; you can use “Trial Period” add-on from Membership 2 > Add-ons

    Cheers,
    Oguz

    Hi,

    I think again i am not able to explain my question again. Currently we are not using the Guest membership since we want the users to get register as well. So currently we are using the standard membership type and have created a standard membership type with name Guest membership with 15 days trial and the payment is set to 0 and once user trial period is over it restricts user to the visitor level. We are using user_register hook. Can you tell me if a standard membership gets expired is it still available for renew. Is there any hook or workaround for that to filter guest membership if used before. I am sharing screenshots as well this time.

    https://prnt.sc/kg5w3k

    https://prnt.sc/kg5xj4

    Best Regards,

    Plugin Support Nastia – WPMU DEV Support

    (@wpmudev-support9)

    Hello @sameernxb

    Hope you’re doing well!

    Our developers provided some custom code to solve the issue you have. You can remove the “Signup” button using the ms_view_shortcode_membershipsignup_button

    Add the following code into the functions.php of your theme. Replace 59 with the membership ID.

    add_filter('ms_view_shortcode_membershipsignup_button', function( $button, $membership, $subscription ){
    
        if ( ! is_user_logged_in() ) {
            return $button;
        }
    
        if ( 59 == $membership->id ){
            $post_args = array(
                    'post_type'     => MS_Model_Relationship::get_post_type(),
                    'post_status'   => 'any',
                    'fields'        => 'ids',
                    'nopaging'      => true,
                    'post_author'   => get_current_user_id()
                );
    
            $subscription_ids = get_posts( $post_args );
    
            foreach ( $subscription_ids as $subscription_id ) {
                $subscription = MS_Factory::load( 'MS_Model_Relationship', $subscription_id );
                $membership_id  = $subscription->membership_id;
    
                if ( $membership_id == $membership->id ) {
                    return '';
                }
            }
    
        }
    
        return $button;
    }, 20, 3 );

    Hope this helps!

    Cheers,
    Nastia

    Plugin Support Nastia – WPMU DEV Support

    (@wpmudev-support9)

    Hello @sameernxb

    Hope all is well!

    We’ve not heard from you in a while. I’ve marked this ticket as resolved for now, but if you need anything else at all, we’re here for you, please just reopen the ticket or create a new one.

    Cheers,
    Nastia

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Provide User Access To Guest Membership Only Once’ is closed to new replies.