Display if a post is protected

I want to visually display if a post is protected on the overview of posts (with a lock image i.e.). Furthermore, I would like to change the "post is protected" page so that the excerpt of the post is shown and the rest of the post is protected.

  • aristath
    • Recruit

    Hello there @Arne, I hope you're well today!

    I want to visually display if a post is protected on the overview of posts (with a lock image i.e.). Furthermore, I would like to change the "post is protected" page so that the excerpt of the post is shown and the rest of the post is protected.

    I'm afraid these modifications are currently not possible out of the box and would require a lot of custom coding...
    When a post is protected, it is redirected to the protected content page, so there's no way to actually display a lock, or the excerpt, because we are no longer on the post itself but on the protected content page.
    I'm not sure if and and how this would be possible...
    However I have notified some of my more capable colleagues coding-wise on this issue, hopefully they might have an idea about this.
    Otherwise you might want to create a new post in our Jobs Board on https://premium.wpmudev.org/wordpress-development/ so that a skilled developer can create these customizations for you.

    Cheers,
    Ari.

  • Arne
    • New Recruit

    Hi Ari,

    Is there a function to check what the access level of a post is?
    I found out that you can check which level a user is on/which subscription a user has. If I can check which access level is required for a post, I can implement what I want.

  • aristath
    • Recruit

    Getting the access level or active subscription of a user is easy... Posts are a completely different story!

    I looked at the plugin code but couldn't find a way to check this... Hopefully one of the colleagues I have notified about this will know more about how to do this.

    Cheers,
    Ari.

  • Hoang Ngo
    • Code Slayer

    Hi @ Arne,

    I hope you are well today and I'm very sorry about the delay.

    For you need, firstly, you can a member levels by the function get_level_ids() locate in wp-content/plugins/membership/classes/Membership/Model/Member.php

    After you can get the level ids, so you can check with the table m_membership_rules, get the record have rule_area = post, that will return the post that current level can access.

    This way, you can know which posts the current member can access :slight_smile:.

    If you have any issues please don't hesitate to let us know so we can assist.

    Best Regards
    Hoang

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.