Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter TomJ37

    (@tomj37)

    Nope, just missed the last reply email notification.

    Yeah I typed most of that, as it was to show anexample, not actual code. You can do a 1 line function as mentioned to call wp_handle_upload, and it will bring the error.

    function my_hook() {
        wp_handle_upload($file, $args);
    }
    

    and get the result of breaking the forms.

    Just the 2 important factors to re-create, hook in to that hook and fire wp_handle_upload or any other handle_upload and it errors. That’s all you need to re-create.

    Thread Starter TomJ37

    (@tomj37)

    I gave you everything you need right there to re-produce.

    Hook in to:
    forminator_custom_form_submit_field_data

    then use any of the wp handle upload functions on the form i.e.

    wp_handle_upload()

    so as simple as this causes the error for me:

    
    add_filter('forminator_custom_form_submit_field_data','my_custom_function', 11, 2);
    
    functionn my_custom_function( $form_data, $form_id ) {
    //Loop and a Switch case to do stuff with form data. Here's upload only part.
    foreach($form_data as $k => $field) {
      switch($field['name']) {
      case 'upload-1':
    	if( isset( $field['value']['file'] ) && $field['value']['file']['error'] === 0 ) {
    	if( !empty($field['value']['file']['tmp_name']) ) {
    		$have_image = true;
    		$image = $field['value']['file'];
    	}
    }
    
    break;
      }
    }
    
    if( true === $have_image ) {
    //This will cause error						
    $upload = wp_handle_upload( $image, array('test_form' => false) );
    //Do other things
    }
    return $form_data;
    }
    

    I’ve even removed all other code and left 1 line to call wp_handle_upload on $form_data[‘upload-1’][‘value’][‘file’] = same result. If I don’t use a handle_upload function, no error from your form.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)