GravityForm Form Restrictions - Schedule [RESOLVED]

In the form settings is there a way to schedule the form limit, based on a specific days in the week other than date range?

Right now I currently have it 188 entries per day and I want to be able to get it on Tuesday, Wednesday, and Friday.

Hi Jerry. There is no built in setting for that. It sounds like you want to allow 188 entries for each of the three days, but no entries on any other days?

You could use this to limit the form to 188 entries per day:

But then you would need to separately NOT show the form on any day other than Tue/Wed/Fri. To do that, you could normally use some PHP and the gform_get_form_filter:

However, the Gravity Wiz code already uses gform_get_form_filter, so I think you could take the code and modify it slightly to consider the day first, before even considering the entry limit. I think the Gravity Wiz code is a good place to start with using the gform_get_form_filter.

Hi Chris,

I believe the last solution will work fine. Will do some experiments on this.

Thanks,
Jerry

Ok, cool. Let us know what you come up with or if you get stuck.

Did I do this correctly? I’m trying to get the time range between 7am and 7pm, once it hits 7pm, the form will not be available til 7am. I’m quiet new to PHP.

add_filter( 'gform_get_form_filter_1', 'custom_schedule', 10, 2 );
function custom_schedule( $form_string, $form ) {
	$startTime = new DateTime('07:00');
	$endTime = new DateTime('19:00');
    if ( $startTime >= $endTime ) {
        $form_string = '<p>We are closed today, please return tomorrow to make your booking.</p>';
    }
 
    return $form_string;
}

I don’t know if that is correct or not. Did you try it?

I figured it out with additional code. Works like a charm.

add_filter( 'gform_get_form_filter_4', 'custom_schedule', 10, 2 );
function custom_schedule( $form_string, $form ) {
    $start = '07:00:00';
    $end = '19:00:00';
    $now = date("H:i:s");


    if($start < $end) {

	    // if current time is past start time or before end time

	    if($now <= $start || $now > $end){
		    $form_string = '<p>We are closed today, please return tomorrow to make your 
booking.</p>';
	    }
    }

    // else time frame is within same day check if we are between start and end

    else if ($now <= $start && $now >= $end) {
		    $form_string = '<p>We are closed today, please return tomorrow to make your 
booking.</p>';
    }

   return $form_string;
}
1 Like

Cool. Thank you for sharing that.