fauzanjeg

Give User Role Editor to Access All Media

Mar 10th, 2021 (edited)
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. /** Give User Role Editor to Access All Media */
  2. function give_user_role_editor_to_access_all_media() {
  3.     /* Check if user is editor role or not */
  4.     if ( in_array( 'editor', (array) wp_get_current_user()->roles ) && ! current_user_can( 'manage_options' ) ) {
  5.         /* For Show ALl Media in Grid View */
  6.         add_filter( 'ajax_query_attachments_args', 'show_all_media_for_editor_child', 99 );
  7.  
  8.         /** Grid View */
  9.         function show_all_media_for_editor_child( $query ) {
  10.             $query['author'] = '';
  11.             return $query;
  12.         }
  13.  
  14.         /* For Show ALl Media in List View */
  15.         remove_action( 'pre_get_posts', array( JNews\AccountPage::getInstance(), 'users_own_attachments' ) );
  16.     }
  17. }
  18. add_action( 'init', 'give_user_role_editor_to_access_all_media' );
Add Comment
Please, Sign In to add comment