Last active
October 23, 2015 08:38
-
-
Save phpbits/3ce950c3c4ba6b2cb2de to your computer and use it in GitHub Desktop.
Hide Attachment
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 | |
/* | |
* Hide Media Images | |
*/ | |
add_filter( 'posts_where', 'hide_attachments_wpquery_where' ); | |
function hide_attachments_wpquery_where( $where ){ | |
global $current_user; | |
if( !current_user_can( 'manage_options' ) ) { | |
if( is_user_logged_in() ){ | |
if( isset( $_POST['action'] ) ){ | |
// library query | |
if( $_POST['action'] == 'query-attachments' ){ | |
$where .= ' AND post_author='.$current_user->data->ID; | |
} | |
} | |
} | |
} | |
return $where; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment