Skip to content

Instantly share code, notes, and snippets.

@rahul3883
Created March 22, 2017 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahul3883/e4498817c745b9513653bbdbb4dfc4a0 to your computer and use it in GitHub Desktop.
Save rahul3883/e4498817c745b9513653bbdbb4dfc4a0 to your computer and use it in GitHub Desktop.
Allow only pdf documents on upload
<?php
/**
* Allow only pdf documents on upload.
*
* Only allow documents which has pdf extension.
*
* @param array $allowed_types Allowed types of media to upload.
*
* @return array Allowed types of media to upload
*/
function tmp_rtm_change_allowed_types_documents( $allowed_types ) {
if ( isset( $allowed_types['document'], $allowed_types['document']['extn'] ) ) {
// change allowed document type to pdf only.
$allowed_types['document']['extn'] = array( 'pdf' );
}
return $allowed_types;
}
add_filter( 'rtmedia_allowed_types', 'tmp_rtm_change_allowed_types_documents', 999, 1 );
@rahul3883
Copy link
Author

Place this code snippet in a php file in mu-plugins folder of your site

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment