Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #7187
    ryanolton
    Participant

    Hello,

    I have a custom user role that can edit the posts of specific users. That custom role can also view the media uploaded by those users. The code below was working but stopped after a recent update to the plugin.

    Any suggestions on how this can be fixed?

    
    add_action('pre_get_posts','users_own_attachments');
    function users_own_attachments( $wp_query_obj ) {
    
        global $current_user, $pagenow;
    
        if( !is_a( $current_user, 'WP_User') )
            return;
    		
    	if( ($current_user->ID == 12 || $current_user->ID == 13) && ( 'upload.php' != $pagenow ) && ( ( 'admin-ajax.php' != $pagenow ) || ( $_REQUEST['action'] != 'query-attachments' ) ) )
    		return;
    
    	if( ( 'edit.php' != $pagenow ) && ( 'upload.php' != $pagenow ) && ( ( 'admin-ajax.php' != $pagenow ) || ( $_REQUEST['action'] != 'query-attachments' ) ) )
    	//if( ( 'upload.php' != $pagenow ) && ( ( 'admin-ajax.php' != $pagenow ) || ( $_REQUEST['action'] != 'query-attachments' ) ) )
    		return;
    
        if( !current_user_can('delete_pages') )
            //Disable below to activate Agency Admin Role? Works anyway but IF statement above changed. Switched off again ... showing all posts to authors
    		$wp_query_obj->set('author', $current_user->id );
    
        return;
    }
    

    In the profiles of users 12&13, under: “Posts/Pages/Custom Post Types Editor Restrictions”, I have “What to do” set to “Look at roles” and “with author user ID (comma separated)” includes the list of users that they can edit.

    Thanks,
    Ryan

    #7188
    ryanolton
    Participant

    Some more info, I’m using the pro version of the plugin (4.58) and WordPress 5.3.6.

    I have a similar setup on my staging server and when I downgrade the plugin to version 4.57, the media library items are showing again.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.