Support » Plugin: User Role Editor » Restrict "Editors" from viewing media that others have uploaded

  • Resolved designlabCPH

    (@designlabcph)


    Hi there – Really hope you can help me out, before I lose all my hair…

    Exactly where should I tick off, if I want to prevent “Editors” (that by default can see all media in library, when uploading/inserting new media) from seing all other media than what they have uploaded themselves?

    aka – How to restric anyone from viewing other users media when inserting new media – apart from administrators, naturally?

    I’m beginning to lose my mind over this issue – albeit it’s most likely due to my lacking knowledge 🙂

    http://wordpress.org/extend/plugins/user-role-editor/

Viewing 15 replies - 1 through 15 (of 20 total)
  • (I should say, that most posts they have acess to, are custom posts…)

    Plugin Author Vladimir Garagulia

    (@shinephp)

    Hi,

    There is no such capability in WordPress to manage your problem with single click in User Role Editor. Additional coding, like a plugin, needed for that. I have a draft related to the subject. But it stopped working under WordPress 3.5. If I resolve that, I will return here with decision.
    Thanks for a feature request.

    … Just like the codesnippets that worked for 3.4 did not work on my install…
    Would be SO great. The last days while searching, I have seen quite a few asking the same, but no working solution to the 3.5…
    Thank you for considering it 🙂

    Plugin Author Vladimir Garagulia

    (@shinephp)

    I’m almost ready to publish plugin, which limits view for Media Library and Posts list for items uploaded/created by their owner herself, but for Contributor and Subscriber roles only. Media Library code uses the same ‘edit_others_posts’ capability to check if user can edit uploaded image. Thus, as ‘Editor’ has ‘edit_others_posts’ capability she can see and edit any post and any item from Media Library and it is not sense to hide them from such user.
    What do you think?

    Sounds excellent! 🙂

    I do still think it would be more “distraction-free” if even editor primarily sees the images connected to the current post they’re editing (as standard view, but I see your point on letting them see all images) – As one would usually upload new images to that post if editing, not re-use from the library? (or maybe I’m wrong on that one *lol*)

    It would also make the popup load faster, if you have a large library.

    Could you maybe sneak in an option to make “images from this post” as “standard view” (instead of all library as it is now), even for editors?
    But they can then still choose to see the whole library via the dropdown as they have access?

    As far as I can tell, I’m far from the only one, who would appreciate that, and to me it makes perfect sense to expand your plugin with that little functionality, if possible?

    After searching 3 days, last night I fell over this solution, to make the default view in the library limited to the current post, if it can be any help:

    <?php
    /**
     * Plugin Name: Pre-select post specific attachments
     */
    
    add_action( 'admin_footer-post-new.php', 'wpse_76048_script' );
    add_action( 'admin_footer-post.php', 'wpse_76048_script' );
    
    function wpse_76048_script()
    {
        ?>
    <script>
    jQuery(function($) {
        var called = 0;
        $('#wpcontent').ajaxStop(function() {
    
                $('[value="uploaded"]').attr( 'selected', true ).parent().trigger('change');
                called = 1;
    
        });
    });
    </script>
        <?php
    }

    and then I added this css to my custom admin css, to hide the first dropdown:

    .media-frame-content .attachment-filters:first-child {
    display:none;
    }

    Found them here: http://wordpress.org/support/topic/wp-35-any-way-to-default-add-media-to-upload-files and here: http://wordpress.stackexchange.com/questions/76125/change-the-default-view-of-media-library-in-3-5

    Plugin Author Vladimir Garagulia

    (@shinephp)

    Good point! I’m fully agree with you about this post only default view option for media library.

    Plugin Author Vladimir Garagulia

    (@shinephp)

    Hi,
    I published plugin to exclude others posts and media library items from view of authors and contributors. Additional options for user convenience as you wrote above are added.
    http://wordpress.org/extend/plugins/view-own-posts-media-only/
    It will be good to read about your testing results. Thanks in advance.

    Shawn

    (@shawnwyatt-1)

    It would be neat to add a feature to work with something like User Role Editor (http://wordpress.org/extend/plugins/user-role-editor), where I can select other defined roles (outside of admin) to have all media access. For me, I would have basic users have limited access with this plugin, but then I have made a advance user role where I would like to allow them greater access to all user media. Just a thought.

    *Update* Actually, I now see that my advance users DO have access to all the users media files. The basic user only sees their own uploaded files. Cool!!

    Plugin Author Vladimir Garagulia

    (@shinephp)

    Thanks for the suggestion.
    “View Own Post Media” plugin uses ‘edit_others_post” capability by default now. It could be useful to allow plugin users to customize that. I will add such option to the next release.
    *Update*. Oh! I missed your updated post. That’s good.

    Thanks a lot, this plugin is exactly what I needed!

    You are the man Vladimir this is exactly what I was looking for!!!

    Hey guys,

    You could also, instead of installing an extra plugin, make use of the ‘posts_where’ filter in your theme when you want to limit the view of attachments to the ones uploaded by the current user:

    add_filter( 'posts_where', 'devplus_attachments_wpquery_where' );
    function devplus_attachments_wpquery_where( $where ){
    	global $current_user;
    
    	if( is_user_logged_in() ){
    		// we spreken over een ingelogde user
    		if( isset( $_POST['action'] ) ){
    			// library query
    			if( $_POST['action'] == 'query-attachments' ){
    				$where .= ' AND post_author='.$current_user->data->ID;
    			}
    		}
    	}
    
    	return $where;
    }

    That’s a bit more performing I guess 🙂

    Thanks timocouckuyt, works great!

    Well I installed the plugin and they can still see all the media on the pages. I don’t know about the posts since the site isn’t really a posting type site. I want each person to only see their media for their page only. Any clues?

    hello timocouckuyt
    i have been trying to solve this problem for a while.
    where would I place this code? themes functions.php? or could it be placed in a child theme functions.php
    thank you

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Restrict "Editors" from viewing media that others have uploaded’ is closed to new replies.