Skip Navigation

[Resolved] Conditional button

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

Problem:
How to display conditional button

Solution:
you can use conditional shortcode [wpv-conditional] to display conditional output.

You have two options - either you should use custom shortcode that returns true or false based on your number of posts count condition or you can return total number of posts counts as per your conditional criteria and return count and with [wpv-conditional] shortcode use the custom shortcode.

You can find proposed solution, in this case, with the following reply
https://toolset.com/forums/topic/conditional-button/#post-746693

Relevant Documentation:

- https://toolset.com/documentation/legacy-features/views-plugin/using-shortcodes-in-conditions/#checking-custom-shortcodes

- https://toolset.com/documentation/programmer-reference/views/using-custom-functions-in-conditions/#custom-functions

This support ticket is created 6 years, 8 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 6 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#745912

I have a Theater Groups directory made with Toolset. There are two User roles: Theater and Group.

The user Group has a CPT group and the CPT "group" has a CPT child "Hiring".
The theater user has a CPT theater and the CPT theater has a CPT child "contract".
That is, the CPT "contract" has two parents "CPT Group" and "CPT theater".

When a theater user logs in, you can see in each group profile a button to create a CPT "contract". That is, when a theater enters the view of a group it creates a CPT "contract" that is child of CPT Theatre and CPT Group.

Up to here everything is correct. What I need is for that button to be shown only if the following requirements are met:

1º- The number of contracts of the group is less than three. Since no group can act more than 3 times.

2º- The number of CPT hired theater tickets is less than three. And also the total number of CPT contracts is less than 45.

In short, the problem I want to solve with this is the following:

There are a total of 45 contracts, 20 theaters and 20 groups. Each theater has to choose a minimum of two groups and each group will have at least 2 performances and a maximum of 3.
This is because 20 theatres x 2 contracts = 40 contracts. Thus all the groups and all the theatres would have 2 contracts. But being 45, there are 5 contracts, which will choose the theaters in order of application, and no group or theater can have more than three contracts.

If someone has another proposal to solve it, I am willing to study it. Thank you.

#746693

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - you can use conditional shortcode [wpv-conditional] to display conditional output.

You have two options - either you should use custom shortcode that returns true or false based on your number of posts count condition or you can return total number of posts counts as per your conditional criteria and return count and with [wpv-conditional] shortcode use the custom shortcode.

- Using that custom shortcode with the [wpv-conditional] shortcode.
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/#checking-custom-shortcodes

OR

Create custom function and use inside [wpv-conditional] shortcode.
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-custom-functions-in-conditions/#custom-functions