All Topics
Filter edit.php for a CPT so user can only see ‘mine’ mosts
Trying this again. Hi there! prior to installing the admin columns pro plugin I was using the following function to filter the edit.php page so that users of a certain role can only see those posts where they are they author. After installing admin columns pro it looks like that function no longer works and all users can see all posts created regardless of whether or not they’re the author. Are you able to recommend a way to do this while still keeping admin columns pro installed? Thanks!!
/**
* Force the 'mine' view on the 'edit-post' screen
*/
function posts_for_current_author_tickets($query) {
global $pagenow;
if( 'edit.php' != $pagenow || !$query->is_admin )
return $query;
if( !current_user_can( 'edit_others_posts' ) ) {
global $user_ID;
$query->set('author', $user_ID );
}
return $query;
}
add_filter('pre_get_posts_tickets', 'posts_for_current_author_tickets');
You must be logged in to reply to this topic.