[resolved] Access to media library (2 posts)

  1. Prolet
    Posted 3 years ago #

    I use a little snippet to restrict an access to media library:
    function my_files_only( $wp_query ) {
    if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/upload.php' ) !== false ) {
    if ( !current_user_can( 'level_5' ) ) {
    global $current_user;
    $wp_query->set( 'author', $current_user->id );
    add_filter('parse_query', 'my_files_only' );

    When a user click on "Media" ---> "Library" will see only it's own media files. That is great for me.

    The problem is when the user want to "Add a Media". The the user is able to see all files in the library and to operate with all of them, which is not what I want.

    Can you advise me, please, how to a solve the problem.

    Thank you in advance!

  2. Prolet
    Posted 3 years ago #

    Problem solved with very simple, easy to use plugin called
    View Own Posts Media Only

Topic Closed

This topic has been closed to new replies.

About this Topic