1

There are plenty of solutions for limiting access to view your own uploaded media but I was wondering if it was possible to limit media to a user role ( e.g. author's can see all other author's media files).

If not, could it be possible to see all user's uploaded media except the media uploaded by an admin?

0

1 Answer 1

-1

You can restrict users to seeing only their own uploaded media with this piece of code:

<?php
/*
Plugin Name: Manage Your Media Only
Version: 0.1
*/

//Manage Your Media Only
function mymo_parse_query_useronly( $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', 'mymo_parse_query_useronly' );
?>
1
  • User Levels were introduced in WordPress 1.5, they were replaced by Roles and Capabilities in WordPress 2.0, and were finaly deprecated in WordPress 3.0. Maybe you replace(edit/change your answer) it with the correct user role/capability?
    – Charles
    Feb 8, 2016 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.