Membership plugin: invite code for specific subscription

Hello, I'm using your Membership plugin on a site of mine.
It's the site for a physical product, and I need to differentiate 3 levels.

- Visitor
- Registered User
- Product Owner

Most of the contents must be visible to everyone;
some contents must be hidden to visitors;
a few contents must be strictly for product owners.

I'd like to use the Invitation Code feature to achieve this, like "insert the product Serial # to access this level" (I'd insert manually all the S.N. as invite codes).

The problem I'm facing is that apparently, either you require invite codes for EVERY level, or for none at all. But considering my specific need, this makes little sense.

I want to allow free registration to the "registered user" level (with no code), and limit the "owner" level only to those that have physical access to a unit.

Simply said... require invitation code only for the most advanced level.

I have a decent understanding of PHP, so I'm open to any solution implying some (guided) customization. Eventually, I can settle for a good workaround. :slight_smile:

If my question is not perfectly clear, ask anything.

Thanks a lot in advance.
Max

  • Jude

    Hi there @Max

    Hope you're doing great !!

    I don't think this is the best way to set this up. However if you wish to proceed the file you should look at is wp-content/plugins/membership/membershipincludes/addons/simple.invitecodes.php

    There are two actions there which control this behaviour

    add_action( 'membership_subscription_form_registration_presubmit_content', 'M_AddSimpleInviteField' );
    
    add_action( 'bp_signup_validate', 'M_AddSimpleInviteFieldProcess_BP' );

    Basically add logic here to check if the level matches you business user and ONLY then accept invite code. For all other levels simply validate as true.

    Cautionary note: editing core files is not reccomended unless you know what you're doing and even then you'll need to repeat this on updates.

    Cheers
    Jude

  • Max M.

    Hello and thanks for the quick reply! :slight_smile:

    I don't think this is the best way to set this up.

    I guess you're talking about core files editing, but if you're talking about the whole idea of using invite codes, feel free to share a different solution. :slight_smile:

    As for the file you pointed me to, thanks.
    I would add an if statement, but what variables should I use, to get this result?

    Example pseudocode:

    if $subscription == owner {
    add_action( 'membership_subscription_form_registration_presubmit_content', 'M_AddSimpleInviteField' );
    
    add_action( 'bp_signup_validate', 'M_AddSimpleInviteFieldProcess_BP' );
    }
    endif;

    I don't expect it to be correct, it would be great if you could help me with it.

    Also, there must be some way to change the plugin behavior without touching the core code, but I never tried anything similar to this case, would you care to share some tips if possible?

    Thanks, regards

  • Max M.

    Hello, I know that double-posting is bad form, but... "bump". :slight_smile:

    Can I get slightly more detailed indications on how to achieve my goal?
    Please consider that while I said that I have an understanding of php, that doesn't mean I'm an expert. I could probably work with just the infos I got up to now, but I fear it would take forever. :smiley:

    Thanks.

    Also, please consider this as a feature request for future updates.
    Being able to select invite codes (and whether they're needed at all) based on the membership levels would be a H-U-G-E advantage. You might say it's a niche market, but you'll be surprised at how many uses it could have, if you try to imagine.

    Special, invite-only membership levels for confirmed customers, or for partners and distributors; coupon-like (but one-time-then expire) usage to access exclusive content or deals based on offline; club membership sales offline... marketing uses could be many, it would be very a GREAT feature to have of the box.

    One that could impress your customers, IMHO. So please think about it. :slight_smile:

  • Michael Bissett

    Hey @Max M., hope you don't mind me jumping in here. :slight_smile:

    Given the situation, it sounds like you may wish to hire a developer, as this would go into more than what I could detail here in the thread. To share my own thoughts on the matter, it doesn't seem like you'd be looking to wrap this code in an if tag:

    add_action( 'membership_subscription_form_registration_presubmit_content', 'M_AddSimpleInviteField' );
    
    add_action( 'bp_signup_validate', 'M_AddSimpleInviteFieldProcess_BP' );

    But you should be able to use a remove_action call on both the "M_AddSimpleInviteField" & the "M_AddSimpleInviteFieldProcess_BP" functions:

    https://codex.wordpress.org/Function_Reference/remove_action

    (though if you're not planning to use BuddyPress, you can just remove the first function)

    The thing would be though, the writing of your own custom coupon function, and adding it to the "membership_subscription_form_registration_presubmit_content" action. You may be able to use an if statement inside of that function, and detecting the subscription inside of that. You may wish to look at lines 3-13 of:

    /membership/membershipincludes/includes/payment.form.php

    For inspiration on how to go about obtaining the ID for the subscription being signed up for.

    For what it's worth, hope this helps! :slight_smile:

    Kind Regards,
    Michael

    P.S. In regards to feature requests, you'd want to post those over here:

    https://premium.wpmudev.org/forums/forum/feature-suggestions#question

    As they're more visible over there for folks to vote on. :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.