Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gravity Wiz // Gravity Forms // Daily Form Schedule
<?php
/**
* Gravity Wiz // Gravity Forms // Daily Form Schedule
*
* Allow your form schedule to apply daily.
*
* @version 1.0
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
* @link http://gravitywiz.com/
*
* Plugin Name: Gravity Forms Daily Form Schedule
* Plugin URI: http://gravitywiz.com/
* Description: Allow your form schedule to apply daily.
* Author: Gravity Wiz
* Version: 1.0
* Author URI: http://gravitywiz.com/
*
* Usage:
*
* 1. Install and activate.
* 2. Set your form schedule via Form Settings › Restrictions › Schedule form.
* a. Specify your desired daily start and end times via the Start and End Time settings.
* b. Leave the Start and End Date inputs EMPTY!
*
* That's it. This super simple plugin will automatically ensure that your schedule will apply daily. 🙂
*/
add_filter( 'gform_pre_render', function( $form ) {
if( rgar( $form, 'scheduleForm' ) ) {
if( ! $form['scheduleStart'] ) {
$form['scheduleStart'] = date( 'm/d/Y', current_time( 'timestamp' ) );
}
if( ! $form['scheduleEnd'] ) {
$form['scheduleEnd'] = date( 'm/d/Y', current_time( 'timestamp' ) );
}
}
return $form;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.