Skip to content

Instantly share code, notes, and snippets.

@pranali333
Last active March 6, 2017 13:44
Show Gist options
  • Save pranali333/6821d413d5f91382a8ace3209fc5d351 to your computer and use it in GitHub Desktop.
Save pranali333/6821d413d5f91382a8ace3209fc5d351 to your computer and use it in GitHub Desktop.
Restrict rtMedia uploader view for author of the custom post.
<?php
//Function to restrict rtmedia uploader view for author
function restrict_rtmedia_uploader( $allow, $section ) {
// Add Your Post Type Here
$ctp = '';
if ( $ctp == get_post()->post_type ) {
if ( get_post()->post_author == get_current_user_id() ) {
$allow = true;
} else {
$allow = false;
}
}
return $allow;
}
add_filter( 'rtmedia_allow_uploader_view', 'restrict_rtmedia_uploader', 10, 2 );
?>
@pranali333
Copy link
Author

pranali333 commented Mar 6, 2017

//Here is the sample code to keep the upload option hidden by default until user clicks on it.

function restrict_rtmedia_uploader_slide() {
$ctp = '';
if ( $ctp == get_post()->post_type ) {
if ( get_post()->post_author == get_current_user_id() ) {
?>
<style>
#shortcode-upload-media + .rtm-tab-content-wrapper {
display: none;
}
</style>
<script>
jQuery(document).ready(function(){
jQuery( '#shortcode-upload-media' ).on( 'click', function() {
jQuery( '#shortcode-upload-media + .rtm-tab-content-wrapper' ).slideToggle();
} );
} );
</script>
Upload
<?php
}
}
}
add_action( 'rtmedia_before_uploader', 'restrict_rtmedia_uploader_slide' );

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