Restrict file types for file upload fields

Enable different file type restrictions on individual file upload fields.

File Type Restrictions Based on Custom Field

Filter

– upme_before_upload_profile_files, upme_after_upload_profile_files

Description

– Define file type restrictions on individual file field. Following example considers 2 file fields for mp3 and PDF while applying different file type restrictions. Once the file is uploaded, file types are reset to default.

Parameters

– User ID, Custom field meta key, Various parameters(Currently empty array)

Usage
add_action('upme_after_upload_profile_files','upme_after_upload_profile_files',10,3);
function upme_after_upload_profile_files($userid, $clean_key, $params){

	$upme_save->allowed_extensions 	= array("image/gif", "image/jpeg", "image/png"); 
	$upme_save->allowed_exts = array('gif','png','jpeg','jpg');
}

add_action('upme_before_upload_profile_files','upme_before_upload_profile_files',10,3);
function upme_before_upload_profile_files($userid, $clean_key, $params){
	global $upme_save;
	if('pdf_field' == $clean_key){
		$upme_save->allowed_extensions 	= array("application/pdf");        
		$upme_save->allowed_exts 		= array('pdf');
	}elseif('mp3_field' == $clean_key){
		$upme_save->allowed_extensions 	= array("audio/mpeg", "audio/mp3");        
		$upme_save->allowed_exts 		= array('mp3');
	}
}

Get your copy of User Profiles Made Easy on CodeCanyon