File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
gp-advanced-save-and-continue Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Gravity Perks // Advanced Save & Continue // Draft Groups by Page
4+ * https://gravitywiz.com/documentation/gravity-forms-advanced-save-continue/
5+ *
6+ * Create draft groups where only drafts saved from the current URL will be displayed. For example, if you're using the
7+ * same form on multiple pages, you can use this snippet to display drafts saved from the current page only.
8+ */
9+ add_filter ( 'gpasc_form_resume_tokens ' , function ( $ tokens , $ form_id ) {
10+
11+ // Set ignore parameters to false if you would like parameters to be included in identifying unique pages.
12+ $ ignore_parameters = true ;
13+
14+ if ( is_ajax () ) {
15+ return $ tokens ;
16+ }
17+
18+ $ target_value = $ _SERVER ['REQUEST_URI ' ];
19+ if ( $ ignore_parameters ) {
20+ $ target_value = strtok ( $ target_value , '? ' );
21+ }
22+
23+ foreach ( $ tokens as $ index => $ token ) {
24+ // If token is specifically passed via parameter, don't interfere.
25+ $ query_token = rgget ( 'gf_token ' );
26+ if ( $ query_token && $ query_token === $ token ['token ' ] ) {
27+ continue ;
28+ }
29+ $ token_path = $ token ['form_path ' ];
30+ if ( $ ignore_parameters ) {
31+ $ token_path = strtok ( $ token ['form_path ' ], '? ' );
32+ }
33+ if ( $ token_path !== $ target_value ) {
34+ unset( $ tokens [ $ index ] );
35+ }
36+ }
37+
38+ return array_filter ( $ tokens );
39+ }, 10 , 2 );
You can’t perform that action at this time.
0 commit comments