Skip Navigation

[Resolved] Nesting Non-Toolset Shortcode in Conditional Statement Doesn’t Work

This thread is resolved. Here is a description of the problem and solution.

Problem: I'm trying to use a third party non-Toolset shortcode in a conditional HTML statement, but it's not working as expected.

Solution: Be sure to register any third party shortcodes in Toolset > Settings > Frontend Content > Third party shortcode arguments.

Relevant Documentation:
https://toolset.com/documentation/user-guides/shortcodes-within-shortcodes/
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/

This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by aaronM-9 6 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#907880
temp.jpg

I am trying to display some content if one of three conditions is met. However, the content is not being displayed even though the output should be producing a positive result.

<p>author [wpv-post-author format="meta" meta="ID"]</p>
<p>user [wpv-user field="ID"]</p>
<p>friendship [be-get-connection userid1="[wpv-post-author format="meta" meta="ID"]" userid2="[wpv-user field="ID"]" attribute="connection-friend"]</p>
<p>[wpv-conditional if="( $(wpcf-member-privacy-posts) eq 'public' ) OR ( '[wpv-post-author format="meta" meta="ID"]' eq '[wpv-user field="ID"]' ) OR ( '[be-get-connection userid1="[wpv-post-author format="meta" meta="ID"]" userid2="[wpv-user field="ID"]" attribute="connection-friend"]' eq '1' )"]</p>
<h2>Start a Conversation</h2>
<p>[wpv-view name="view-conversation-add" groupid="0" eventid="0"]</p>
<p>or statement with 3 possibilities works</p>
<p>[/wpv-conditional]</p>
<p>[wpv-conditional if="( '[wpv-post-author format="meta" meta="ID"]' eq '[wpv-user field="ID"]' )"]conditional statement with only 1 condition works</p>
<p>[/wpv-conditional]</p>

In the attached screenshot, you'll see that the author and user are both 10, so one of the three conditions in the logic should produce a positive result, but they are not. However, when I remove two of the conditions then the one that should produce the positive result does.

When I remove the [be-get-connection] shortcode then the statement starts working again, so it would appear the problem is with nesting a non-Toolset shortcode into the conditional statement even though that shortcode produces a numerical output (as evidenced in the screenshot). Can you tell me if there are any requirements I need to do when creating shortcodes to help ensure they will work properly when nested inside a [wpv-conditional] shortcode? Thanks.

- Aaron

#908302

I've been doing some more research on this and have learned - correct me if I'm wrong - that you cannot nest shortcodes inside of others unless the top-level shortcode calls the nested shortcode through the function do_shortcode(). Am I correct in interpreting that this means it would be impossible to nest my own custom shortcodes inside of Toolset shortcodes? If this is correct, I will need to find another way of working around this.

- Aaron

#908415

Hi, first you can try registering the third-party shortcode in Toolset > Settings > Frontend Content > Third party shortcode arguments. This will help get around the do_shortcode issue you mentioned. If this doesn't work, I can take a closer look.

#908554

Too easy! That worked. Awesome - sorry if that was a dumb question. I'm sure that's buried in the documentation somewhere and I missed it. Thanks a million. This will make things a lot easier.

- Aaron