• Resolved xbmcgotham



    I am trying to hide text using the following conditions, however, whenever I add a nested condition, it will not work correctly. Separately the conditions work fine.
    When using the example below, the “oil” is hidden, but the other text is still shown, and the last/second shortcode [/restrict] is for some reason shown on the web page as well.

    Please advice how I can make this work. I like to show only the “whole” text if you are in a particular role/level and when you are member of that role/level you can only see “Oil” if you are part of the role/level called “oil”.


    Example snippet from in a page:

    [restrict role=”role1″]
    [restrict level=”oil”]Oil[/restrict]

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


    Thank you for reporting this.

    I will look into this and see if I can reproduce the issue.

    Does the same thing happen if you change the outer shortcode to use a level instead of role check? (e.g. you could create a new level and synchronize it with role1)



    Thanks for getting back to me. Not able to check for you at this moment, however in the mean time, please let me know what you have found. As I need to know if I can use this plugin as intended. 🙂

    Kind regards

    Hi, @intoxstudio

    I was hoping you have had time to check this issue. I really need to know if you have a solution, as I have to go live with the web site.


    @intoxstudio any update for me?

    Plugin Author Joachim Jensen


    Apologies for the delayed response here.

    I tried to setup your example and can confirm that I get the same result.

    I looked further into the issue, and found this about the Shortcode API: https://codex.wordpress.org/Shortcode_API#Nested_Shortcodes

    > the parser will fail if a shortcode macro is used to enclose another macro of the same name

    So it seems like this is a known “bug” for all WordPress shortcodes, and the only current workaround would be to create 2 different shortcodes that do the same thing, e.g. [restrict-sub ...]

    What do you think about such a solution?

    Thanks for looking into this. I guess that would be the only solution for now. 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Nested Conditions’ is closed to new replies.