Error when saving content with ACF file fields
-
Hello,
I use custom fields created with Advanced Custom Fields. Some of them are file (upload) fields placed in repeater field.
When user with limited capabilities role (e.g. Contributor) tries to save the post warning appears and file(s) are not being uploaded:Warning: is_file() expects parameter 1 to be a valid path, array given in /wp-content/plugins/wp-cerber/cerber-load.php on 6936I did some debugging and var_dump($files) shows this structure:
array (size=2) 'field_568a1dd843f06' => string '' (length=0) 'field_568c535b182f4' => array (size=2) 'row-0' => array (size=1) 'field_568c5387182f5' => string '' (length=0) 'row-1' => array (size=1) 'field_568c5387182f5' => string '(...)' (length=25)And this is my fix proposal (line 6923):
foreach ( $_FILES as $file ) { if ( is_array( $file['tmp_name'] ) ) { foreach ( $file['tmp_name'] as $file_temp_name ){ if( is_array( $file_temp_name ) ){ $files = array_merge( $files, array_map( 'array_shift', $file_temp_name ) ); } else { $files[] = $file_temp_name; } } } else { $files[] = $file['tmp_name']; } }Best regards,
Tomek
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Error when saving content with ACF file fields’ is closed to new replies.