Hello @juliushg,
according to the WordPress documentation, you can’t nest a shortcode inside another shortcode when they have the same name:
The parser will fail if a shortcode macro is used to enclose another macro of the same name
This means that you can do this:
[shortcode-a]
[shortcode-b]
[shortcode-c]
[/shortcode-b]
[/shortcode-a]
but you can’t do this:
[shortcode-a]
[shortcode-a]
[shortcode-a]
[/shortcode-a]
[/shortcode-a]
In your case, using these shortcodes:
[display-frm-data {options}]
[private role=administrator]content[/private]
[/display-frm-data]
should work, but the following form won’t work:
[display-frm-data {options}]
[display-frm-data {options}]
[private role=administrator]content[/private]
[/display-frm-data]
[/display-frm-data]
because there are two nested shortcodes with the same name display-frm-data.
Let me know, please.
Well, actually I can. Maybe I took for granted that you would know that Formidable Forms works that way. I invoke the second view with a shortcode inside the first, just like that, and it works.
[display-frm-data {options}]
[display-frm-data {options}]
content here
[/display-frm-data]
[/display-frm-data]
That is useful and necessary for the plugin to work properly, because I’m setting a category in the first shortcode and passing a parameter to the second to show entries in that category (a field).
What won’t work is the private shortcode inside the second nested display.
This is:
[display-frm-data {options}]
Other content here
[private role=administrator]This works fine, hidden[/private]
[/display-frm-data]
But…
[display-frm-data {options}]
[display-frm-data {options}]
Other content here, works fine
[private role=administrator]This is not hidden[/private]
[/display-frm-data]
[/display-frm-data]
Instead of hiding the content, it shows all the shortcode syntax there:
[private role=administrator]Does not hide[/private] This is shown as is.
Thanks for your response. Your plugin is great. I understand that I maybe should contact the FF developers, unless the solution is in yours. Can you think what is happening?
At this point I have no explanation why [display-frm-data] shortcode works even with two nested shortcodes with the same name.
My advice is to ask the developer of this plugin and ask why you can’t nest Private Content shortcode in the third level.
But, before asking, try this: add a third level of the same shortcode. It works up to the second level. Does it work with a third one having the same name? I mean:
[display-frm-data {options}]
[display-frm-data {options}]
[display-frm-data {options}] <--- Does it work?
[/display-frm-data]
[/display-frm-data]
[/display-frm-data]
Let me know.
Yes, it works. The 3rd level nesting can be done.
But I had a little surprise:
I injected the Private code in the three levels of the nested views, and now it only does not work in the last level. But in level one and two works perfectly.
Anyway, the two level nesting is documented in the FF docs, here: https://formidableforms.com/knowledgebase/advanced-view-concepts/#kb-set-up-a-nested-view
So I experimented a little and added a third level, and it worked, but now that happened. Not a big deal, but I would like to understand what is causing this issue.
Tell me if I can privately send you a link to the page of my site where it shows the result, in your email perhaps? Or when may I contact you, just to explore this.
Julius,
But I had a little surprise:
I injected the Private code in the three levels of the nested views, and now it only does not work in the last level. But in level one and two works perfectly.
My advice is to contact the developer of Formidable Forms and ask him if it’s possible to nest the shortcode of another plugin inside multiple FF nested shortcodes. Tell him the various tests you made, especially when you nest two and three levels.
Then, let me know.