Extra “uploads” added in path

Resolved in a completely different way. Googled this, so technically not my own answer, but does the job: // ACF upload prefilter function gist_acf_upload_dir_prefilter($errors, $file, $field) { // This filter changes directory just for item being uploaded add_filter(‘upload_dir’, ‘gist_acf_upload_dir’); } // ACF hook, set to field key of your file upload field add_filter(‘acf/upload_prefilter/key=field_5b2b0326ea0e1’, ‘gist_acf_upload_dir_prefilter’); // … Read more

Email Attachment from Form Submit

Alright so I feel rather stupid now, especially because I have found the solution to my own problem right after posting my question here, but also because I would have found it much earlier had I properly debugged my page (implemented a way to look at return error codes). Anyways… As stated in my EDIT … Read more

Convert (-) and (escape) signs to (_) when uploading files on wordpress media library automatically

You can use sanitize_file_name hook for this. function my_sanitize_file_name( $filename ) { $chars_table = array( ‘ ‘ => ‘_’, ‘-‘ => ‘_’, ); $friendly_filename = preg_replace( array_keys( $chars_table ), array_values( $chars_table ), $filename ); return strtolower( $friendly_filename ); } add_filter( ‘sanitize_file_name’, ‘my_sanitize_file_name’, 10 ); It will also convert letters to lowercase to avoid conflicts on … Read more