• Resolved berbercito

    (@berbercito)


    Hi,
    First of all thanks for the excellent plugin.
    I have it installed in a local testing website.
    I would like to know if there is a way to find out if the current page is FOR MEMBERS ONLY. A kind of function to use in the template so as to detect if the page is public or not. This way, I can have control over which message to display.
    I would be so grateful if you could shed some light on this.

    Thanks in advance!!

    • This topic was modified 3 years, 8 months ago by berbercito.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @berbercito

    Are you referring to shortcode or PHP functions?

    Here are links to shortcode docs:

    Restrict content on a page/post to logged in users
    https://docs.ultimatemember.com/article/177-restrict-content-on-a-page-post-to-logged-in-users

    Restrict content on a page/post to specific users community role
    https://docs.ultimatemember.com/article/226-restrict-content-on-a-page-post-to-specific-users-community-role

    Regards,

    Thread Starter berbercito

    (@berbercito)

    Hi and thanks for your quick reply.

    I actually refer to a piece of code to place in the page.php template.

    Let′s say a function like this: is_restricted_page()

    Basically, the idea is to check all pages using a given WordPress template if its content is public or restricted to members.

    Thanks again!

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @berbercito

    Do you want to restrict the page by Role or User Status? There’s already a UM Content Restriction settings on the Pages. Are you going to disable it and just use the PHP function to check the Role or User Status for restriction?

    Regards,

    Thread Starter berbercito

    (@berbercito)

    Hi,

    The pages are restricted by user role.
    I am not going to disable it.

    I just need a way to detect if a page is restricted or not so as to show a different header depending on the referer page.

    For example, if the user comes to a restricted page from the homepage we′ll show him a specific message and if he comes from services we′ll show him a different message, and so on.

    In order for this to work, we need a mechanism that detects if the page is restricted. If it is restricted the user will be shown a message and if it is not restricted he will the content of the page.

    I hope you understood what I am after.

    Thanks again!!

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @berbercito

    Sorry for the late response.

    You can try this function is_restricted.

    e.g. UM()->access()->is_restricted( $post_id )

    Feel free to re-open this thread by changing the topic status to “Not Resolved” so that we can get back to you.

    Regards,

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Detect if a page is for members only’ is closed to new replies.