Is there a way to display the Start and End dates/times that are selected in 'Schedule Form' section (located on the Advanced tab of the Form Settings)?
It would be nice to tell the user when the form will expire and/or is valid for.
Thanks
Is there a way to display the Start and End dates/times that are selected in 'Schedule Form' section (located on the Advanced tab of the Form Settings)?
It would be nice to tell the user when the form will expire and/or is valid for.
Thanks
You can use the gform_pre_render hook and access these $form object properties:
[php]
$form['scheduleStart']
$form['scheduleStartHour']
$form['scheduleStartMinute']
$form['scheduleStartAmpm']
$form['scheduleEnd']
$form['scheduleEndHour']
$form['scheduleEndMinute']
$form['scheduleEndAmpm']
$form['scheduleMessage']
Hi Chris,
Ok, I'm a little lost on this... This is my attempt, but I am getting errors:
// Add Start/End Date/Time on Gravity Form
add_filter("gform_pre_render", "we_display_formdates");
function we_display_formdates($form){
//only for form id 9
if($form["id"] != 9)
return $form;
//Adding items to field id 8. Replace 8 with your actual field id. You can get the field id by looking at the input name in the markup.
foreach($form["fields"] as &$field)
if($field["id"] == 8){
return $form['scheduleStart'];
}
return $form;
}
Can you help me tweak it to make it work? :)
Can you post a link to your form and then explain what message you want, based on what dates, and where it should be displayed?
This is something that I'd be interested in too. Did you ever get it working? If so, can you share the code?
WedEndev is still active here so I will leave this open in case they did get it working and would like to post their resolution.
@aechols, if you like, you can post your question here and let us know what you would like to do and we can help you. Thanks.
It would be nice to make a page that shows active forms to the public. If I could grab the start and end dates/times, I could make a page that would show currently active forms with the title and due date/time.
We've embedded the form into a single page with the form number, and uses GET to grab the number from the URL so we don't have to manually embed the form into a page every time. Most of our forms are applications, so if we could use that data to populate another page, we won't have to add/remove the links manually and then everything would be automated.
You can make a page that shows active forms. Those start and end times though are for a single form. So, you would first have to return an array of all active forms, then loop through them, and extract the end times and display that as well. It can be done using built-in Gravity Forms functions.