This is not related to who the current user is. What I'm trying to accomplish is to hide any products on the shop and archive pages if the product's author is Admin. I tried searching on here and other places, but anything I find is related to if the current user is logged in or is admin. Any assistance is greatly appreciated!
function hide_product_by_user_role( $query ) {
$authors = ( array ) $product->authors; // obtaining product author -- this is wrong
if ( $query->is_main_query() && is_woocommerce() && $authors[0] != 'administrator' ) {
.... what do I do here?
}
}
add_action( 'pre_get_posts', 'hide_product_by_user_role' );