• Resolved songiuno

    (@songiuno)


    Is it possible, or is it already functional and I’m doing it wrong, to nest the shortcode to further restrict view within an existing restriction? For instance, if I have a restriction to family and friends, and then within that section I want to further restrict a paragraph to only family, can I do that?

    example:
    [private role=”custom” custom_role=”family,friends”]
    Only family and friends can read this.
    [private role=”custom” custom_role=”family”]
    Only family can read this, friends are excluded.
    [/private]
    Family and friends can read the rest of this page.
    [/private]

    Not a big deal if this is not a function. I was just wondering so I know what restriction strategeies can be used.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Aldo Latino

    (@aldolat)

    According to the WordPress Codex, the parser will fail when two shortcodes with the same name are nested:

    However 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:

    [tag-a]
       [tag-b]
          [tag-c]
       [/tag-b]
    [/tag-a]

    but you can’t do this:

    [tag-a]
       [tag-a]
       [/tag-a]
    [/tag-a]

    However, as of version 4.3, Private Content has two shortcodes that you can use:

    [private] and [ubn_private].

    In other words, you can use both [private] and [ubn_private].

    This means that you could use these two shortcodes for your nesting purposes, for example:

    [private]
       [ubn_private]
       [/ubn_private]
    [/private]

    I can’t try this now, but please let me know if you can.

    Thread Starter songiuno

    (@songiuno)

    I struggled with the nesting test but finally got it to work. So yes it does work as you mentioned. Problem solved!

    • This reply was modified 5 years ago by songiuno.
    Plugin Author Aldo Latino

    (@aldolat)

    Wow, great! Thank you @songiuno!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Nesting the shortcode’ is closed to new replies.