Home › Forums › Backend Issues (wp-admin) › Not compatible with this code? › Reply To: Not compatible with this code?
Since I’m using it for the post type “course”, I changed the post_type=post into post_type=course.
However, the count still doesn’t work (it still counts everything).
Also, the 1st part of your code (that you last posted) doesn’t work (to show only the authors content) – while an earlier example of you did work – so I used the code below for the first part and added the “Fix post counts” count only.
What I’m currently using (working code).
// So authors can only see their own content (e.g. courses etc)
function posts_for_current_author($query) {
if( !$query->is_admin )
return $query;
$screen = get_current_screen();
if ($screen->base === 'post')
return $query;
if( !current_user_can( 'activate_plugins' ) ) {
global $user_ID;
$query->set('author', $user_ID );
}
return $query;
}
add_filter('pre_get_posts', 'posts_for_current_author');
I haven’t been able to get the count correct, see http://d.pr/i/Ijhs.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.