Skip Navigation

[Resolved] Can I use custom shortcodes that take parameters in conditional outputs?

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

Problem:

The issue is that the customer was having issues with his custom shortcode in our Views Conditional shortcode. In this case the user was having a missmatch of his quotes.

Solution:

The solution here is to first ensure that your shortcode is added to the views 3rd party shortcode arguments. To do this you need to go to Toolset > Settings > Frontend and then add your shortcode name to your views 3rd party shortcode arguments.

This support ticket is created 7 years 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 6 replies, has 2 voices.

Last updated by melS 7 years ago.

Assisted by: Shane.

Author
Posts
#593399

Is something like this (below) possible?

[wpv-conditional if="( '[is_author user_id="[wpv-user field=\"ID\"]"]' eq '1' )"]Yes[/wpv-conditional]

I have a custom shortcode that takes a user_id param, which works fine and returns a 1 or 0, but I'd like to use it inside a conditional block to show/hide checkboxes inside a view/form, and so I need to pass in a field from within a loop.

#593492

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mel,

Thank you for contacting our support forum.

Yes this is possible but in order for you to add your shortcode to work in our views plugin you will need to go to Toolset > Settings > Frontend and then add your shortcode name to your views 3rd party shortcode arguments.

Please let me know if this helps.

Thanks,
Shane

#593494

I already registered the custom shortcode, but it's still not liking the tags, could it be the single quote / double quote stuff - it looks fairly messy - what's the accepted way to write these tags in this way?

(
Worth noting this is:
Current user ID shortcode inside a:
Registered custom shortcode inside a:
Conditional output shortcode
)

#593501

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mel,

Yes i believe its the quotations as well.

Try this format.

[wpv-conditional if="( '[is_author user_id="[wpv-user field='ID']"]' eq '1' )"]Yes[/wpv-conditional]


Please let me know.
Thanks,
Shane

#593512

That worked! Thank you!

Is there an "else" block for the conditional output that will avoid having two calls to the shortcut codes?

#593531

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mel,

Awesome i'm happy I was able to help you.

Unfortunately we don't have an else statement so multiple Conditionals will be required.

Thanks,
Shane

#593541

Thanks for your help 🙂