• Resolved dikig

    (@dikig)


    May be I’m stupid but for any reason this plugin does not allow me to restrict pages and contents to selected user roles. Besides this all seems to work as expected.
    Using the proposed restriction mechanism with e.g.
    “[restrict userlevel=“editor“] your restricted content goes here [/restrict]”
    Never shows this string independet of the actual user role. I always get the red alert string that the current user were not logged in, no matter, which role I’m using (even admin)..
    The only thing, which works is using this (undocumented) restriction mechanism, omitting the ‘userlevel=..’:
    “[restrict] your restricted content goes here [/restrict]”
    Which distinguishes between being logged in with any role showing the restricted text and being logged out, showing the red alert.
    Can it be that it has to do with the point that my WP installation is in German and thus internally might use differently spelled user roles unknown to the plugin.

    Many thanks
    Dieter

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi Dieter,

    I think you’re right with regards to the translation, but I’ll need to confirm it. If so, we’ll get it fixed up in the next release. I’ll let you know more when after I look into it.

    Can you show me a screenshot of your page edit screen, showing how you have entered the shortcode?

    Thread Starter dikig

    (@dikig)

    Many thanks John for your fast response. I’d love to attach a schreenshot, however, I wasn’t able to figure out how this can be done in this forum ??
    Hopefully this link will work for you: https://www.dikig.de/files/restrict_plugin_screenshot1.jpg

    Please let me know if I can help you with this issue (e.g. doing tests or similar).

    Many thanks
    Dieter

    Thanks. Can you show me one with the userlevel specified that doesn’t work? I tried it on my local install and it worked, so I was curious if I’m doing something different than you.

    Thread Starter dikig

    (@dikig)

    Hi John,
    I made a couple of screenshots and hope this is what you asked for.
    Please download it from: https://www.dikig.de/files/attachment2

    Find attached as well the file “shortcodes.php” where I tried to get information about the internal userlevel string. It obviously prints the userlevel provided with the restrict statement. The code simply consists of two echo statements. You can see the results in the screenshots directly under the header.

    To my suprize it now seems to work, at least with the roles ‘author’ (German: Author) and ‘administrator’ (German ‘Administrator’). I did several tests before and never saw it working – I’m confused !!!!
    I will do some tests with other user roles as well. Unfortunately my WP instance has a couple more roles than the ones you listed in your documentation, may be I selected the wrong ones during the tests.

    Many thanks for your patience
    Dieter

    Thanks!

    You’ll definitely need to use the English versions of the words in the userlevel setting, and they should be lowercase instead of starting with the capital letter. This should work:

    [restrict userlevel="author"]Only authors can see this[/restrict]

    Thread Starter dikig

    (@dikig)

    Thanks John,

    obviously there was a basic misunderderstanding on my side as I thought that higher level roles automatically include the roles with less capabilities. Most likely this and spelling issues was the reason that I was not able to get the restrictions for a special level running.
    Please give me some time to invstigate this in more detail.

    By the way, is there a simple solution to get the userlevel of the current user (exact spelling)?

    Thanks
    Dieter

    Thread Starter dikig

    (@dikig)

    Hi John,

    I just took the time to comprehensively check the contents access vs. roles and the conclusion is: all works perfectly and higher user role levels include the lower user role levels as expected.

    Here you can find the results: https://www.dikig.de/files/170927_User_roles_and_contents_access.xlsx

    Please do not ask me, why it did not work initially. There must have been spelling issues.
    Many thanks for your great support and please take my apologies for wasting your time to some extent.

    Dieter

    Hey Dieter,

    No worries! Glad to hear it’s working for you. Thanks for the update!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Cannot get content restrictions based on user roles’ is closed to new replies.