Skip to content

Commit 07b26f5

Browse files
committed
Fix PHP Warning: Invalid argument supplied for foreach() when saving a repeater without a file sub field. Fixes WPUserManager/wpum-custom-fields#62
1 parent 902834c commit 07b26f5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

includes/wpum-fields/types/class-wpum-field-repeater.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ public function get_posted_field( $key, $field ) {
213213

214214
$posted = isset( $_POST[ $key ] ) ? $this->sanitize_posted_field( $_POST[ $key ], $field['sanitizer'] ) : [];
215215

216+
if ( ! isset( $_FILES[ $key ] ) ) {
217+
return $posted;
218+
}
219+
216220
if ( isset( $_FILES[ $key ] ) && ! empty( $_FILES[ $key ] ) ) {
217221
$files = $this->upload_file( $key, $field );
218222
}
@@ -229,6 +233,7 @@ public function get_posted_field( $key, $field ) {
229233
$posted[ $index ][ $key ] = $file;
230234
}
231235
}
236+
232237
return $posted;
233238
}
234239

0 commit comments

Comments
 (0)