• Resolved Xarajevo

    (@xarajevo)


    Is there a way to use shortcodes to display page content only to users who are not logged in?

    I tried: [restrict role=”not-logged-in”][/restrict], but that did not work.

    Then, I created an access level and linked it to the user role ‘Not logged-in” in the backend of the Restrict User Access plugin. In my page I then included:
    [restrict level=”not-logged-in”][/restrict]. That too did not work.

    I also tried excluding all my access levels:
    [restrict level=”!low, !medium, !high”][/restrict]
    No effect.

    In all cases the content was always displayed, even when users were logged in.

    Is there a way to do this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Joachim Jensen

    (@intoxstudio)

    Your second method is the right way of doing it.

    When using the shortcode, it’s important that the name of the level is exactly the same as what’s stated in the Access Level overview. As in this screenshot: https://ps.w.org/restrict-user-access/assets/screenshot-1.png?rev=1363762

    Thread Starter Xarajevo

    (@xarajevo)

    Thanks for your answer. The name I used is indeed exactly the same. However, I see that in your screenshot you linked the level ‘free’ to ‘Subscriber’.
    I guess that means users need to subscribe, before obtaining access to the free content?

    In my own case, it is linked to ‘Not logged-in’.
    I would like to offer specific content to people who don’t have an account (yet).
    Would that make a difference?

    Thread Starter Xarajevo

    (@xarajevo)

    Update: it seems there is a difference between the homepage and other pages. On other pages, I got it to work as intended.

    On the homepage however, all content gets displayed always, regardless of the level of the user or whether they are logged in or not.

    Do I still need to activate something, somewhere?

    Plugin Author Joachim Jensen

    (@intoxstudio)

    It shouldn’t matter whether a level is synced to a specific role, or whether members are added manually.

    When you say that the homepage works differently, are you then referring to the restrict shortcode, or are you using conditions to restrict the whole page?

    If you are using conditions and what to restrict the homepage, you should select Static Pages: Front Page.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show content only to users who are not logged in, using shortcodes’ is closed to new replies.