Skip to content

Commit 1cce1a0

Browse files
authored
gpnf-disable-sessions.php: Updated to prevent the session from ever being created vs deleting it after creation.
1 parent b5e97bb commit 1cce1a0

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
<?php
22
/**
3-
* Gravity Perks // Nested Forms // Disable Session Storage
3+
* Gravity Perks // Nested Forms // Disable Sessions
44
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
55
*
66
* Instruction Video: https://www.loom.com/share/348e9e70999a43eaaf73cf0c820161aa
77
*
8+
* Given how much data can be captured in a child entry, Nested Forms provides a safety net by storing
9+
* submitted entry IDs in a cookie so that if the user accidently refreshes the page or closes the tab
10+
* their submitted entries can be restored.
11+
*
12+
* If you would prefer that Nested Form fields function like other fields where the data is not preserved,
13+
* use this snippet to disable Nested Forms sessions.
814
*/
9-
add_filter( 'gform_pre_render', function( $form ) {
10-
if ( empty( $_POST ) && class_exists( 'GPNF_Session' ) ) {
11-
$session = new GPNF_Session( $form['id'] );
12-
$session->delete_cookie();
13-
}
14-
return $form;
15-
} );
15+
add_action( 'wp_ajax_gpnf_session', 'gw_gpnf_disable_session', 9 );
16+
add_action( 'wp_ajax_nopriv_gpnf_session', 'gw_gpnf_disable_session', 9 );
17+
function gw_gpnf_disable_session() {
18+
remove_action( 'wp_ajax_gpnf_session', array( gp_nested_forms(), 'ajax_session' ) );
19+
remove_action( 'wp_ajax_nopriv_gpnf_session', array( gp_nested_forms(), 'ajax_session' ) );
20+
}

0 commit comments

Comments
 (0)