jonasterc / LIMITAR-O-ACESSO-DOS-ARQUIVOS-DA-BIBLIOTECA-

0 stars 0 forks source link

LIMITAR O ACESSO DOS ARQUIVOS DA BIBLIOTECA DE ACORDO COM AS PERMISSÕES DO USUÁRIO #1

Open jonasterc opened 6 years ago

jonasterc commented 6 years ago

add_action( 'pre_get_posts', 'restrict_media_library' ); function restrict_media_library( $q ) { global $current_user, $pagenow; $set = false; if( 'admin-ajax.php' == $pagenow || $_REQUEST['action'] == 'query-attachments' ) $set = true; if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/upload.php' ) !== false ) $set = true;

if( current_user_can( 'author' ) && $set )
    $q->set( 'author', $current_user->ID );

}

jonasterc commented 6 years ago

duplicate-post.3.2.1.zip wp-slimstat.4.7.5.3.zip