Skip to content

Commit f523e97

Browse files
committed
Added support for populating the "is_new" parameter when it is set as a dynamic population parameter and removing this parameter from the query string on subsequent Entry Blocks URLs.
1 parent 3644b1c commit f523e97

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

gp-entry-blocks/gpeb-add-new-entry.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public function init() {
4747

4848
add_filter( 'gfme_edit_url', array( $this, 'set_edit_url' ), 10, 3 );
4949

50+
add_filter( 'gpeb_edit_form_entry', array( $this, 'populate_is_new_parameter' ) );
51+
52+
add_filter( 'gpeb_cleaned_current_url', array( $this, 'remove_is_new_parameter' ) );
53+
5054
}
5155

5256
public function is_add_entry_request( $is_add_entry_request ) {
@@ -63,6 +67,23 @@ public function set_edit_url( $edit_url, $form_id, $entry_id ) {
6367
return $edit_url;
6468
}
6569

70+
public function populate_is_new_parameter( $entry ) {
71+
if ( ! rgget( 'is_new' ) ) {
72+
return $entry;
73+
}
74+
$form = GFAPI::get_form( $entry['form_id'] );
75+
foreach ( $form['fields'] as $field ) {
76+
if ( $field->inputName === 'is_new' ) {
77+
$entry[ $field->id ] = 1;
78+
}
79+
}
80+
return $entry;
81+
}
82+
83+
public function remove_is_new_parameter( $url ) {
84+
return remove_query_arg( 'is_new', $url );
85+
}
86+
6687
}
6788

6889
# Configuration

0 commit comments

Comments
 (0)