I've embedded a gravity form in one of my WP pages. What I'd like to do is create a condition where I only embed/display the form Monday - Friday...
Any thoughts?
Thanks
I've embedded a gravity form in one of my WP pages. What I'd like to do is create a condition where I only embed/display the form Monday - Friday...
Any thoughts?
Thanks
You could create a new page template to use for displaying your form that has this bit of php in it, then assign that to the Page in your admin:
<?php
//Give what day of the week it is. Returns Sunday through Saturday.
$day = date("l");
switch ($day) {
case Monday: case Tuesday: case Wednesday: case Thursday: case Friday:
echo do_shortcode("[gravityform id=1 title=false description=false ajax=false]");
break;
}
?>
You can set your form ID appropriately here and all of the other parameters as you see fit. You could also include a separate case for Saturday and/or Sunday to display some kind of message like so:
<?php
//Give what day of the week it is. Returns Sunday through Saturday.
$day = date("l");
switch ($day) {
case Monday: case Tuesday: case Wednesday: case Thursday: case Friday:
echo do_shortcode("[gravityform id=1 title=false description=false ajax=false]");
break;
case Saturday: case Sunday:
echo "It's the weekend, no form today!";
break;
}
?>
Thanks Rob! I'll one of those solutions...
Hi Rob,
Added a line for EST:
<?php
date_default_timezone_set(timezone_name_from_abbr("EST"));
$today = date("l");
if ($today == "Tuesday" || $today == "Wednesday"){
echo $today;
echo do_shortcode("[gravityform id=6 title=false description=false ajax=false]");
}
?>
Unfortunately, this won't pull up the id=6 form... I think it may have something to with having conditional logic. This code works for all my other forms that don't contain conditional fields
here's the page:
http://50.116.66.243/~ab27853/test-page2/
Any thoughts?
Thanks,
You probably need to enqueue the scripts and/or styles, check this out:
http://www.gravityhelp.com/documentation/page/Gravity_form_enqueue_scripts
Aaah. Nice! worked perfectly. thanks again Rob
Right on! Glad to help.