Skip to content

Commit c62ed0b

Browse files
committed
gpnf-override-parent-merge-tag-on-submission.php: Added support to rename uploaded files in child entries.
1 parent 5a8881b commit c62ed0b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

gp-nested-forms/gpnf-override-parent-merge-tag-on-submission.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ function override_child_entry_input_value( $entry, $field, $child_form, $input_i
122122
$child_entry = GFAPI::get_entry( $child_entry_id );
123123
$value = GFCommon::replace_variables( $default_value, $child_form, $child_entry );
124124
GFAPI::update_entry_field( $child_entry_id, $input_id, $value );
125+
126+
// Added support to force the renaming of uploaded files if the GP File Renamer plugin is active and the version is greater than 1.0.9 because `rename_uploaded_files` method of `GP_File_Renamer` class supports third argument `force` only after 1.0.9.
127+
if ( function_exists( 'gp_file_renamer' ) && defined( 'GP_FILE_RENAMER_VERSION' ) && version_compare( GP_FILE_RENAMER_VERSION, '1.0.9', '>' ) ) {
128+
// Get the updated child entry to rename the uploaded files.
129+
$child_entry = GFAPI::get_entry( $child_entry_id );
130+
131+
// Force the renaming of uploaded files if set.
132+
gp_file_renamer()->rename_uploaded_files( $child_entry, $child_form, true );
133+
}
125134
}
126135

127136
}

0 commit comments

Comments
 (0)