Skip Navigation

[Resolved] conditional by specific date

This support ticket is created 2 years, 10 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 3 replies, has 2 voices.

Last updated by Minesh 2 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#2311509

Hi - I have a view set up with some "register" buttons that link to a registration page. Registration opens on March 15, 2022 at 8:00am - I would like to figure out how to create a conditional statement - can you help me figure out the conditional shortcode?

example
[wpv-conditional if= "right now or today is greater than march 15, 2022 at 8:00am"] BUY NOW BUTTON [/wpv-conditional]

Thank you!

#2311829

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Have you created a custom date field that will hold the value of registration opening date?

If you just want to compare the static date, You can use the conditional block. You can add the conditional block and setup the conditions as given under. Please check the following screenshot:
- hidden link

More info:
- https://toolset.com/documentation/user-guides/views/date-filters/
- https://toolset.com/course-lesson/using-toolset-conditional-block/

#2312599

Thanks for the help.
I'm actually using the older toolset views for this. Basically, how can I create a shortcode that does this:

[wpv-conditional if= "right now or today is greater than march 15, 2022 at 8:00am"] BUY NOW BUTTON [/wpv-conditional]
(the date is a static date)

screencast may help!
hidden link

#2312839

Minesh
Supporter

Languages: English (English )

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

We do not have way to add time with date. To compare date with time we will require to use custom shortcode.

Please try to add the following shortcode to "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/

add_shortcode('is_register_open', 'func_is_register_open');
function func_is_register_open() {
 if(strtotime("now") > strtotime("23 March 2022 8 hours")){
   return 1;
 }else{
   return 0;
 }
}

Where:
- Register shortcode name child-post-exists at :
=> Toolset => Settings => Front-end Content => Third-party shortcode arguments

Use the conditoinal shortcode as:

[wpv-conditional if="( '[is_register_open]' eq '1' )"]
 BUY NOW BUTTON
[/wpv-conditional]