Problem: I would like to use a custom function in a conditional, but I cannot get it to work as expected.
Solution: In this case it is possible to create a custom shortcode instead of a function that adds a filter and returns some result. See the below format for creating a custom shortcode that returns some value, then register the shortcode name in Toolset > Settings > Frontend Content > 3rd-party shortcode arguments.
function paid_memebers_filter() { $value = 'notpaid'; // ... your code should modify $value here if necessary... return $value; } add_shortcode( 'paidviewfilter', 'paid_memebers_filter' );
Then you can use it in a conditional like so:
[wpv-conditional if="( '[paidviewfilter][/paidviewfilter]' eq 'paid' )"] ...paid content... [/wpv-conditional] [wpv-conditional if="( '[paidviewfilter][/paidviewfilter]' eq 'notpaid' )"] ...unpaid content... [/wpv-conditional]
Relevant Documentation:
https://toolset.com/documentation/user-guides/views/shortcodes-within-shortcodes/
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 2 replies, has 2 voices.
Last updated by 4 years, 2 months ago.
Assisted by: Christian Cox.