I am trying to: Limit the upload from a cred front end form to block mp3s, wavs and ogg.
Link to a page where the issue can be seen: hidden link
I used the below snippet for functions.php found in the support forum, which worked for adding the flac type and limiting the wav, but mp3 can still be uploaded.
function my_custom_mime_types( $mimes ) {
// New allowed mime types.
$mimes['flac'] = 'audio/flac';
// Optional. Remove a mime type.
unset( $mimes['wav'] );
unset( $mimes['mp3'] );
unset( $mimes['m4a'] );
unset( $mimes['ogg'] );
return $mimes;
}
add_filter( 'upload_mimes', 'my_custom_mime_types' );
I wish there was a way to filter by file type from within the form itself instead of a functions.php snippet....maybe I missed it and there is, but I did search quite a bit on here.
thanks again, as always - you rock.
I think the mime-type is wrong:
https://stackoverflow.com/questions/10688588/which-mime-type-should-i-use-for-mp3
Note that also each browser sends its variation of a mime type for a specific file.
See also Luo's extensive answer here:
https://toolset.com/forums/topic/hi-i-have-a-frontend-form-for-uploading-stl-files-that-is-not-uploading/#post-261584
It seems you'd have to use audio/mpeg
Related to having the feature within the GUI of Toolset Forms, that's a good idea, you can suggest it to our Product Management here: https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
Ive tried using audio/mpeg.
WP doc says: 'mp3|m4a|m4b' => 'audio/mpeg',
As I understand it----- $mimes['mp3'] = 'audio/mpeg'; the first mp3 is the extension and the second audio/mpeg is the type so the unset( $mimes['mp3'] ); is what to use because the mp3 file extension. I have also tried mpeg anyways but without any luck.
I'm just running in circles. I was hoping you'd have a method specific to cred to limit file types in the cred upload function itself...
I wanted to put an update on how to solve this if anyone stumbles on the same thing. The mime was right, the problem was with another plugin called "snippets" that wasnt always running it in the front end for whatever reason... I used the built in snippet tool within toolset and it solved the weirdness!
Toolset once again has expanded and allowed me to stop using another plugin!!!!! Love toolset! This suite has paid for itself 10x over! I pretty much run a blank theme and toolset and can accomplish 95% of what I need on any given project! thanks again toolset team!
My issue is resolved now. Thank you!