Restrict in WordPress
-
Hello,
I want to allow users with the Customer role to upload “Image only”. I don’t want it to load other types of files. So I want to restrict it. However, I could not define the mine type. Should I define each file type separately? For example, a client should be able to upload an image file with the HEIF extension. Should I define it separately?
I also want to set a limit on qty. For example, it should be able to add up to 3 images. How can do it ?My code is below:
function wpse_restrict_mimes($mime_types){ //Get current user $user = wp_get_current_user(); //Obtaining the role $roles = ( array ) $user->roles; if($roles[0]=='Customer'){ $mime_types = array( //? ); return $mime_types; } } add_filter('upload_mimes', 'wpse_restrict_mimes');
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Restrict in WordPress’ is closed to new replies.