Last active
March 6, 2017 13:44
-
-
Save pranali333/6821d413d5f91382a8ace3209fc5d351 to your computer and use it in GitHub Desktop.
Restrict rtMedia uploader view for author of the custom post.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
//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' );