capacities in multimedia library

Hello, Do you know any way a user uploads a photo site to the multimedia library and another user on the same site with the same permission (role) can not see them?
whenever a user uploads a photo others can see them in the media library and I wish they were private.
The permissions plugin (members) do not add that option.
I would be worth some plugin that modifies "media", add capabilities, or a plugin to upload photos private.
Thanks

  • PC
    • WPMU DEV Initiate

    Hey there @Alvaro

    Thanks for posting on the forums.

    Something like this can help you achieve what you want :

    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' );

    Just add this to your functions.php and it should only allow the person to view the media files uploaded by him/her and not by others.

    Please ensure you take proper backups before you make any code changes.

    I hope that helps. Please feel free to ask if you have more questions on the same.

    Cheers, PC

  • Alvaro
    • WPMU DEV Initiate

    Thanks, I think if that's what I'm looking for. Not much programming. I've added in function.php (/ public / wp-includes), but to access the page is blank.
    What line I have to add?
    What can be happening?
    Thank you so much

  • Alvaro
    • WPMU DEV Initiate

    I have read in various forums.
    Simply add the following code in a php file and add it to the plugin folder.
    It works perfectly.
    Thank you very much.

    <?php
    /*
    Plugin Name: Funciones
    Plugin URI: http://ayudawordpress.com/
    Description: Plugin para liberar de funciones el fichero functions.php y activarlo a placer (o no) .
    Version: 1.0
    Author: Fernando Tellado
    Author URI: http://tellado.es
    License: GPLv2 o posterior
    */

    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' );

  • Alvaro
    • WPMU DEV Initiate

    I write again to say that half works.
    In the admin part of the left (means) if it is true that each user can only view the files. The problem becomes when you walk from your media library to add a photo in "pages" or "product" that is where the problem is.

  • PC
    • WPMU DEV Initiate

    Hello there,

    Sorry to have missed your last post on this one. I had to be away for sometime due to family emergency and could not get back to this any earlier.

    In the admin part of the left (means) if it is true that each user can only view the files.

    So you are able to get this working in Media Library but when a user goes to create post >> add media, they are able to see all items ?

    Please advise.

    Cheers, PC

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.