• Resolved oldcreakyknees

    (@oldcreakyknees)


    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.

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

    (@caseproof)

    Hi @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

    (@oldcreakyknees)

    Hi @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

    (@caseproof)

    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.