I have this code where the authors can see only own posts. I need the authors to see only the products they have created on woocommerce. I know the woocommerce products have no authors by default, but I can add this with a plugin. Whats I want to do is to change this snippet to limit the lists of products in the custom post type of woocommerce.
Someone know the best way to do that?
Thanks!
function posts_for_current_author($query) {
global $pagenow;
if( 'edit.php' != $pagenow || !$query->is_admin )
return $query;
if( !current_user_can( 'manage_options' ) ) {
global $user_ID;
$query->set('author', $user_ID );
}
return $query;
}
add_filter('pre_get_posts', 'posts_for_current_author');