WordPress.org

Ready to get started?Download WordPress

Forums

User Role Editor
[resolved] [closed] Restrict "Editors" from viewing media that others have uploaded (21 posts)

  1. designlabCPH
    Member
    Posted 1 year ago #

    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/

  2. designlabCPH
    Member
    Posted 1 year ago #

    (I should say, that most posts they have acess to, are custom posts...)

  3. Vladimir Garagulya
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  4. designlabCPH
    Member
    Posted 1 year ago #

    ... 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 :)

  5. Vladimir Garagulya
    Member
    Plugin Author

    Posted 1 year ago #

    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?

  6. designlabCPH
    Member
    Posted 1 year ago #

    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

  7. Vladimir Garagulya
    Member
    Plugin Author

    Posted 1 year ago #

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

  8. Vladimir Garagulya
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  9. shawnwyatt
    Member
    Posted 1 year ago #

    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!!

  10. Vladimir Garagulya
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  11. Yaron Guez
    Member
    Posted 1 year ago #

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

  12. rvirvo
    Member
    Posted 12 months ago #

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

  13. timocouckuyt
    Member
    Posted 9 months ago #

    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 :-)

  14. maikunari
    Member
    Posted 8 months ago #

    Thanks timocouckuyt, works great!

  15. aprilajune
    Member
    Posted 8 months ago #

    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?

  16. ucarman2002
    Member
    Posted 6 months ago #

    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

  17. Michael Lenhart
    Member
    Posted 6 months ago #

    @timocouckuyt
    Thx a lot, that was exactly what I was looking for.
    Great Job.
    In combination with this Code from Richard Gabriel http://illuminatikarate.com/blog/wordpress-only-show-authors-their-own-posts-and-media-in-the-admin-area/#comment-17545
    it works great.

    Greetz Michael

  18. Axenstar86
    Member
    Posted 6 months ago #

    the solution by timocouckuyt still works perfectly! Thanks Mate.

  19. lognic
    Member
    Posted 6 months ago #

    sorry for entering here: need some help on how to restrict

    authors from seen and editing other authors content when using a plugin.
    I want to ALLOW authors TO SEE > ONLY IT'S OWN CONTENT

    here is the link of the main post.

    http://wordpress.org/support/topic/adding-capability-for-a-specific-plugin?replies=12#post-4767448

    please help, i have been searching for this but i have not found a solution so far

  20. esmi
    Theme Diva & Forum Moderator
    Posted 6 months ago #

    As per the Forum Welcome, please post your own topic.

  21. shawnwyatt
    Member
    Posted 6 months ago #

    So, how is the timocouckuyt solution applied? Where, which file and does it get overwritten with core updates?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic