gravityflow_step_expiration_timestamp

Description

Use this filter to override the expiration timestamp.

Parameters

ParameterTypeDetails
$expiration_timestampIntegerThe current expiration timestamp (UTC)
$expiration_typeStringThe type of expiration defined in step settings.
$stepGravity_Flow_StepThe current step

Examples

Adjust expiration by a day based on conditional logic.

1
2
3
4
5
6
7
8
9
10
11
12
add_filter( 'gravityflow_step_expiration_timestamp', 'schedule_business_hours', 10, 3 );
function schedule_business_hours( $expiration_timestamp, $expiration_type, $step ) {
    //Ensure you are only adjusting the desired form/step
    if ( $step->get_id() !== 76 ) {
        return $expiration_timestamp;
    }
    $entry = $step->get_entry();
    if ( $entry && isset( $entry['2'] ) && $entry['2'] == 'No Service Level Agreement' ) {
        $expiration_timestamp = strtotime('+1 day', $expiration_timestamp );
    }
        return $expiration_timestamp;
}

Postpones expiration by one day if the expiration day is Saturday/Sunday.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
add_filter( 'gravityflow_step_expiration_timestamp', 'sb_exclude_weekend', 10, 3 );
function sb_exclude_weekend( $expiration_timestamp, $expiration_type, $step ) {
    //Ensure you are only adjusting the desired form/step
    if ( $step->get_id() !== 492 ) {
        return $expiration_timestamp;
    }
     
    $dayOfWeek = date('l');
    if($dayOfWeek  == 'Saturday' || $dayOfWeek == 'Sunday') {
    $expiration_timestamp = strtotime('+1 day', $expiration_timestamp );
    }
     
    return $expiration_timestamp;
}

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?