File type
-
Hello!
First of all, thank you for the great plugin and awesome documentation.I’m trying to add an extra field, which is the file type field and I want to allow attaching only PDF files.
What I did:
1. Added the extra field in function.phpadd_filter( 'submit_job_form_fields', 'frontend_add_extra_fields' ); function frontend_add_extra_fields( $fields ) { $fields['job']['job_attachment'] = array( 'label' => __( 'Attachment', 'job_manager' ), 'type' => 'file', 'required' => false, 'priority' => 10, 'description' => '*pdf only' ); return $fields; }
2. Then I’m trying to filter it:
add_filter( 'job_manager_mime_types', 'filter_allowed_mime_types' ); function filter_allowed_mime_types( $allowed_mime_types ) { if ( 'job_attachment' === $field ) { $allowed_mime_types = [ 'pdf' => 'application/pdf' ]; } else { $allowed_mime_types = [ 'jpg|jpeg|jpe' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', 'pdf' => 'application/pdf', 'doc' => 'application/msword', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'mp4' => 'video/mp4', ]; }
like at tutorial
But it does not work, the system still allows to attach All files (*.*)
I’ve already spent the whole day but can not find out what am I doing wrong?
Please help.
Thank you.
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘File type’ is closed to new replies.