Title: Multiple, nested shortcodes
Last modified: September 8, 2020

---

# Multiple, nested shortcodes

 *  Resolved [oldcreakyknees](https://wordpress.org/support/users/oldcreakyknees/)
 * (@oldcreakyknees)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/multiple-nested-shortcodes/)
 * Hi,
 * I was wondering if it’s possible to combine shortcodes?
 * I’m trying to make it so visitors with certain roles (eg roles A, B and C) who
   access a public page would see one image but other visitors (who are not logged
   in -OR- logged in as a role other than A, B or C) would see a different image.
 * I’ve tried the [members_access role=”A,B,C”] shortcode for the first and nesting[
   members_not_logged_in] and [members_access role=”A,B,C” operator=”!”] shortcodes
   for the second. It works for not logged-in visitors but, for a logged in visitor
   with a role other than A, B or C, no content is shown.
 * Any help would be greatly appreciated.
 * Thanks and best regards.
    -  This topic was modified 5 years, 9 months ago by [oldcreakyknees](https://wordpress.org/support/users/oldcreakyknees/).

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Caseproof LLC](https://wordpress.org/support/users/caseproof/)
 * (@caseproof)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/multiple-nested-shortcodes/#post-13382921)
 * Hi [@oldcreakyknees](https://wordpress.org/support/users/oldcreakyknees/)
 * Shortcodes can be nested in Members, but that particular nesting appears problematic.
   The top-level shortcode is checking if the user has a particular role. Therefore,
   the [members_not_logged_in] portion will never work, because users who aren’t
   logged in will never enter the `[members_access role="A,B,C"]` block. Same is
   true for the `[members_access role="A,B,C" operator="!"]` part.
 * I think that [members_access role=”A,B,C” operator=”!”] shortcode just needs 
   to be moved out from under [members_access role=”A,B,C”].
 * Cheers
 *  Thread Starter [oldcreakyknees](https://wordpress.org/support/users/oldcreakyknees/)
 * (@oldcreakyknees)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/multiple-nested-shortcodes/#post-13382958)
 * Hi [@caseproof](https://wordpress.org/support/users/caseproof/),
 * Thanks for coming back to me.
 * So nesting [members_not_logged_in] and [members_access role=”A,B,C” operator=”!”]
   shortcodes won’t work? That’s a shame.
 * The [members_access role=”A,B,C”] content is already out from under [members_access
   role=”A,B,C”] in a separate section ie:
 * [members_access role=”A,B,C” operator=”!”]
    [members_not_logged_in] < Public 
   content here > [/members_not_logged_in] [/members_access]
 * [members_access role=”A,B,C”]
    < Private content here > [/members_access]
 * All the best
 *  Plugin Author [Caseproof LLC](https://wordpress.org/support/users/caseproof/)
 * (@caseproof)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/multiple-nested-shortcodes/#post-13392843)
 * The [members_not_logged_in] and [members_access role=”A,B,C” operator=”!”] shortcodes
   work, but not inside [members_access role=”A,B,C”] shortcode.
 * I would change the shortcodes from your last message a bit like this:
 *     ```
       [members_access role="A,B,C" operator="!"]
       < Public content here >
       [/members_access]
   
       [members_not_logged_in]
       < Public content here >
       [/members_not_logged_in]
   
       [members_access role="A,B,C"]
       < Private content here >
       [/members_access]
       ```
   
 * Let me know if it works.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Multiple, nested shortcodes’ is closed to new replies.

 * ![](https://ps.w.org/members/assets/icon-256x256.png?rev=3508404)
 * [Members - Membership & User Role Editor Plugin](https://wordpress.org/plugins/members/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/members/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/members/)
 * [Active Topics](https://wordpress.org/support/plugin/members/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/members/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/members/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Caseproof LLC](https://wordpress.org/support/users/caseproof/)
 * Last activity: [5 years, 9 months ago](https://wordpress.org/support/topic/multiple-nested-shortcodes/#post-13392843)
 * Status: resolved