Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Give Selected Role to Access All Media */
- function give_selected_role_to_access_all_media() {
- $allowed_role = array( 'editor', 'author' ); /* allowed role to access all media */
- $user_role = wp_get_current_user()->roles; /* current user role */
- if ( in_array( $user_role[0], $allowed_role ) && ! current_user_can( 'manage_options' ) ) {
- /* For Show ALl Media in Grid View */
- add_filter( 'ajax_query_attachments_args', 'show_all_media_for_editor_child', 99 );
- /** Grid View */
- function show_all_media_for_editor_child( $query ) {
- $query['author'] = '';
- return $query;
- }
- /* For Show ALl Media in List View */
- remove_action( 'pre_get_posts', array( JNews\AccountPage::getInstance(), 'users_own_attachments' ) );
- }
- }
- add_action( 'init', 'give_selected_role_to_access_all_media' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement