WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Access to media library (2 posts)

  1. Prolet
    Member
    Posted 1 year ago #

    Hi,
    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
    Member
    Posted 1 year 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