I’m pretty sure $_REQUEST['post_id']
will hold the post ID you are attaching uploads to. So something like this perhaps:
1 2 3 4 5 6 7 8 9 10 11 |
if ( isset( $_REQUEST['post_id'] ) && $post_id = absint( $_REQUEST['post_id'] ) ) { switch ( get_post_type( $post_id ) ) { case 'document' : if ( ! in_array( $type, array( 'pdf', 'msword', 'vnd.ms-excel' ) ) ) $file['error'] = '...'; break; case 'illustration' : // and so forth } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.