PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Form Submission End Date Validation / Server Time

  1. I'm updating a form / plugin that I build as a silent auction tool and am encountering an issue as it relates to the end time for the form schedule. I have a custom validation tied to gform_validation for the form which successfully checks the bid values against custom post type custom field.

    The issue occurs when I have the form displayed on screen before the end-time and submit the entry after the end-time has passed - the entry is still accepted. If I refresh browser immediately I do see the form give the unavailable message I have provided.

    Is the scheduled form end time not evaluated as a part of the default validation?
    Do I have to parse the form time fields as a part of my custom validation to ensure that submissions are actually provided before the intended time?

    If that is the case - could you share code example of how to build up the form field time values shown below to properly compare to server?

    echo "example: " . $form['scheduleEnd'] . " " . $form['scheduleEndHour'] . ":" . $form['scheduleEndMinute'];

    It may relate to server time details as when I output date('m/d/Y h:i a e O'); in PHP it shows me the server time is 10/06/2011 04:55 pm UTC +0000 and I have set the WordPress (Settings > General) TimeZone to match UTC +0. In my case, this results in having to put the end-time in form advanced settings as +4 of what I really want, but the custom message means I can keep that transparent from users so not horrible.

    When I check the date_created field in wp_rg_lead for the entries I see them as 2011-10-06 16:21:05 which matches the UTC +0.


    Posted 9 years ago on Thursday October 6, 2011 | Permalink
  2. I think I've gotten a working solution:

    $closeTime = strtotime($form['scheduleEnd'] . " " . $form['scheduleEndHour'] . ":" . $form['scheduleEndMinute'] . " " . $form['scheduleEndAmpm']);
    $currentTime = strtotime(date('m/d/Y h:i a'));
    if ($currentTime > $closeTime) {
    	$validation_result['is_valid'] = false;
    	$form["fields"][2]["failed_validation"] = true;
    	$form["fields"][2]["validation_message"] = $form['scheduleMessage'];
    	//$form["fields"][2]["validation_message"] .= "<br/>Current: " . $currentTime . " / Close Time: " . $closeTime;

    Might be something to consider adding as a configurable parameter so that longer forms can keep the 'if you get in the door to start, you have a chance to finish' approach compared to 'deadline = deadline no matter what.

    Posted 9 years ago on Thursday October 6, 2011 | Permalink
  3. Currently the form processing does not take into account the end date. It's only used for the display of the form. But we can certainly look at enhancing this so that it does do this check to ensure this scenario doesn't happen. It won't make it in the 1.6 release but I'll see about getting this added in a subsequent 1.6.X release.

    Posted 9 years ago on Thursday October 6, 2011 | Permalink

This topic has been resolved and has been closed to new replies.