advancedforms / advanced-forms

WordPress plugin to create forms using Advanced Custom Fields
75 stars 14 forks source link

File Upload atatched to Email, instead of link #116

Open MontroseSt opened 1 year ago

MontroseSt commented 1 year ago

Hi, great plugin! I was wondering if the files uploaded on the front end can be attached to the email (instead of a email link)?

Also it would be great to add the option to define a custom upload folder for all form attachments. I used the following code:

// change acf file name "file" to required name add_filter( 'acf/upload_prefilter/name=file', 'secure_upload_prefilter' ); add_filter( 'acf/prepare_field/name=file', 'secure_files_field_display' );

function secure_upload_prefilter( $errors ) {

add_filter( 'upload_dir', 'secure_upload_directory' );

return $errors;

}

function secure_upload_directory( $param ) {

//upload folder $folder = '/wp-content/uploads/_acf-forms';

$param['path'] = WP_CONTENT_DIR . $folder; $param['url'] = WP_CONTENT_URL . $folder; $param['subdir'] = $folder; $param['basedir'] = WP_CONTENT_DIR; $param['baseurl'] = site_url();

return $param;

}

function secure_files_field_display( $field ) {

// update paths accordingly before displaying link to file add_filter( 'upload_dir', 'secure_upload_directory' );

return $field;

}