• Hi Jason,

    PMP is fantastic. I’m using PMP on a BuddyPress site which also has other pages which need to be restricted. All of the memberships are free, but need to be approved first so we’re using Membership level id 1 as a Pending membership, and we allow signups for those.

    Membership level id 2 then, Active Members, are what we convert the Pending members to once their membership is approved.

    That set up works just as expected for protecting posts/pages, etc… but I can’t get the BuddyPress lock down snippet from Github to work yet. I’m sure it’s correct! I just am not understanding how to use it yet to only allow #2 access to the BuddyPress pages.

    https://wordpress.org/plugins/paid-memberships-pro/

Viewing 1 replies (of 1 total)
  • Plugin Author Jason Coleman

    (@strangerstudios)

    That snippet needs to be updated for your specific levels, pages, and groups (if you want to control what groups members go into).

    This line here should be updated to allow level 2 but not level 1: https://gist.github.com/ameeker/5ef1a9f22ceb77805df3#file-gistfile1-txt-L47

    So something like:

    if(!pmpro_hasMembershipLevel() || pmpro_hasMembershipLevel(2))
    {
    	wp_redirect(pmpro_url("levels"));
    	exit;
    }

    This code above now redirects non-members and level 1 members. Level 2 (and any new ones added) will have access to stuff.

    The other thing to check is if the code to detect the page is working. So make sure this is matching on the correct page.

    if(strtolower(substr($uri, 0, 16)) == "/groups/members/")

    If your pages have different URLs, that won’t match. Also note that that is just looking for one specific page. You’ll want to update the conditional to check for other pages you want to block.

    Earlier in the script the $not_allowed array is a list of URLs that no one should have access to (basically a cheap way to deactivate some BuddyPress features). You might not need that or may want to throw in a pmpro_hasMembershipLevel() type check in there as well.

    Sorry this isn’t more straight forward. This is just a script we put together for a specific BuddyPress site on an older version of BuddyPress. We haven’t had anyone pay us to build a easier to use BuddyPress plugin yet.

Viewing 1 replies (of 1 total)
  • The topic ‘Only allow membership level 2 access to BuddyPress pages’ is closed to new replies.