Skip Navigation

[Resolved] multiple conditional fields same form

This support ticket is created 6 years, 7 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 6 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#738684

Tell us what you are trying to do?

I am trying to display a View using 2 different conditional output statements in the same content template.

I have created Courses. Each course uses custom fields. Some courses are OPEN or CLOSED. CLOSED courses have the registration button hidden. See example here: hidden link.

Now I want to add a new custom field so client can choose to SHOW or HIDE a course when the date has passed. My thinking is that I would set this up the same way I did for the registration button. But, It seems as though I can't use 2 conditional statements in the same content template, and I can't nest the conditional statements either.

Here is what I did for the register button:

<div style="margin-bottom: 25px; background-color: #fff; border: 1px solid #ddd; padding: 25px 30px; font-size:14px">
<h5 style="font-size:24px; text-align:center">[wpv-post-title]</h5>
Date(s): [types field="course-dates"][/types]<br>
Faculty: [types field="faculty-name-title"][/types]<br>
Location: [types field="course-location"][/types]<br>
Venue: [types field="course-venue"][/types]<br>
Cost: [types field="course-cost"][/types]<br>
Pay Deadine: [types field="payment-deadline"][/types]<br>
CMEs: [types field="cmes"][/types]<br>
Status: [types field="course-status"][/types]<br>

[wpv-conditional if="( $(wpcf-course-status) eq 'open' )"][types field="course-registration-url" title="Register" class="extra-class" style="display: block; margin-top: 10px; padding: 10px 25px;background-color: #49adde; color: #fff; text-align: center;"][/types][/wpv-conditional]

</div>

What I need help with:

Either a work around so I can SHOW a course based on date AND hide the registration button if the course is CLOSED -or- A way to have the courses automatically expire (and be removed from the View) based on a date reference.

Is there any documentation that you are following?

Nothing available for this

Is there a similar example that we can see?

No

What is the link to your site?

hidden link

#739459

Hello,

For your questions:
Q1) SHOW a course based on date
You can edit the view, add a custom field filter on the date filed "course-dates", for example:
Select items with field: Course dates is a UNSIGNED greater than TODAY()

See our document:
https://toolset.com/documentation/user-guides/date-filters/

Q2) hide the registration button if the course is CLOSED
You can modify your codes from:

[wpv-conditional if="( $(wpcf-course-status) eq 'open' )"] ... [/wpv-conditional]

To:

[wpv-conditional if="( $(wpcf-course-status) eq 'open' ) AND ( $(wpcf-course-dates) lt 'TODAY()' )"] ... [/wpv-conditional]

and test again

More help:
https://toolset.com/documentation/beyond-the-basics/conditionally-show-content/#strike-through-event-dates-that-have-passed