[Resolved] Suggestion : Disable Element “Full Page/Post content”

Home Forums Support Suggestion : Disable Element “Full Page/Post content”

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1549889
    Benjamin

    Hello,

    GP is one inch away of providing a pretty useful function : display/hide (page/post) content based on User Role.

    It has everything except the option to select “Full Page/Post content” in the disable elements window:

    https://dropshare-files.s3-eu-west-1.amazonaws.com/Screen-Shot-2020-11-26-16-15-48.jpg

    this way we could protect the entire page content to be viewed based on user role.

    Thanks for evaluating the idea,

    #1549940
    David
    Staff
    Customer Support

    Hi there,

    try this instead, create a new Hook Element or Block Element.
    Select the Hook > Custom Hook and add: generate_do_template_part

    You can either leave the Hook/Block content empty or add your own custom content for protected pages.

    Then set your Display Rules

    #1552934
    Benjamin

    Thanks for he suggestion, looks like it could indeed work to show/hide the content if needed.

    However it looks like the Display Rules won’t allow me to do what I need:

    I wanted to be able to have basic membership level and display rules made with solely GP.

    e.g. if logged-in User Role is NOT (Membership1 OR Membership2) OR user is not logged in => display “please log in or buy a membership” else display the normal loop content.

    TBH I’ve always wondered why the GP display rules aren’t more developer friendly (like the Widget Logic plugin, e.g. is_page() && is_logged_in())

    #1553144
    Tom
    Lead Developer
    Lead Developer

    The Display Rules aren’t that complex, unfortunately. Once you start adding in OR and AND conditions, things start getting pretty messy.

    It would be sweet to introduce a way to add your own conditions as you’ve mentioned. Not sure what that would look like when it comes to UI, but it’s worth exploring. Noted ๐Ÿ™‚

    #1553414
    Benjamin

    “Not sure what that would look like when it comes to UI, but itโ€™s worth exploring.”

    I think you could offer a simple field like the “Widget Logic” UI, where people could enter pure WP conditionals, like so:

    https://dropshare-files.s3-eu-west-1.amazonaws.com/Screen-Shot-2020-11-27-21-57-06.28.jpg

    Maybe hide this field under an “Advanced configuration” and indicate that what is entered in that field overwrites any configuration made with the “Location/Exclude/Users” UI fields.

    #1553495
    Benjamin

    Humm, actually there is no WP conditionals to check if the current user belongs to a give Role, so in my case even if GP allowed advanced rules, it wouldn’t work…

    #1555355
    Tom
    Lead Developer
    Lead Developer

    The trouble there is then executing those conditions, as they’re just strings at that point. Definitely something worth looking into.

    There is a filter that you can use to add your own conditions as well: https://docs.generatepress.com/article/generate_hook_element_display/

    May be worth playing with ๐Ÿ™‚

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.