WordPress.org

Forums

Paid Memberships Pro
[resolved] Coding for all posts--not just a page. Is this possible? (7 posts)

  1. JuryDuty
    Member
    Posted 2 years ago #

    Loving the Paid Memberships Pro plugin, but I've run across a snag.

    The category checkboxes here seem to only block a posts' actual content area, but I need to also block out other info on the page displayed around the post based on their level: http://www.paidmembershipspro.com/documentation/content-controls/for-posts/

    On the PMP webpage, they state you can use the following php on a page to show or reveal content to a member based on their membership level:

    <?php if(pmpro_hasMembershipLevel('12')) { ?>
    	//Your content here.
    <?php } ?>

    But this doesn't work in this case because it's hardcoding in an actual level, and instead it needs to be able to match whatever category was set in the post.

    (If the post is tagged as level 1 and user is a member of that level, display it, otherwise don't. If the post is tagged as level 2 and user is a member of that level, display it, otherwise don't, etc)

    Make sense?

  2. JuryDuty
    Member
    Posted 2 years ago #

    Just to clarify, essentially, I want the same conditioning that goes around displaying a post based on the category checkbox to also affect another element on the single post page.

  3. Jason Coleman
    Member
    Plugin Author

    Posted 2 years ago #

    Try:

    <?php if(pmpro_has_membership_access()) { ?>
    ...
    <?php } ?>

    That function checks specifically against the current post. You can see that function on line 642 of paid-memberships-pro.php.

  4. JuryDuty
    Member
    Posted 2 years ago #

    This function seems to work to check and see if you have ANY form of membership, but not a specific level.

    So using this tag still lets a "silver" member see content marked with this code on a "gold" level page.

    Is there a way to have it check against the level of the post--without hard-coding in a level? Does that make sense?

    I appreciate your attentiveness to your community.

  5. Jason Coleman
    Member
    Plugin Author

    Posted 2 years ago #

    Edit: The pmpro_has_membership_access() will check if the current user has access to the current post. Not sure what else you are asking for. If you sign up for support at http://www.paidmembershipspro.com, you can post something there and I can give you a more specific answer/bit of code.

    --- Original Post, unrelated to your thread ---
    Here's the full documentation for that function:
    http://www.paidmembershipspro.com/documentation/advanced-techniques/require-membership-function/

    You can pass a level id or name, or an array of such, to check for a specific level.

  6. JuryDuty
    Member
    Posted 2 years ago #

    Hmmm...I'm going to test it again then. That's exactly what I want. I tested it and it seemed to be allowing anyone in as long as they were a member. I'll report back what I find.

    I'm just verifying if PMPro is exactly what will work for me. If so, I'll be signing up for support for sure--if nothing else, just to support this great plugin. Pardon my hesitation, but I just paid $120 for another membership plugin that doesn't work quite right with my setup and I can't get a refund since it's code. :) I just don't want to rush into it LOL

  7. JuryDuty
    Member
    Posted 2 years ago #

    OK, just to follow up, you're right! It worked beautifully. For anyone following this discussion, here are some things to watch out for: You can set checked member levels on individual posts as well as categories when you create the levels. I had checked both in some cases giving me false positives.

    Anyway, that said, this php works great to protect items outside of the post content itself. For me, I had videos outside the post content. So here's the php I ended up using. This hides the video if they don't have access to the post AND displays a large graphic of a video that says "You don't have access to this" in its place. Feel free to use it!

    <?php if(pmpro_has_membership_access()) { ?>
    <div class="video-wrap">
    [Insert code for video here.]
    </div>
    <?php } else { ?>
    <div class="video-wrap">
    <img src="link-to-video-image/no-access-warning-here.png">
    </div>
    <?php } ?>

    Hope this helps someone.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic