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