Add the below code in the functions.php file of your current active theme –
add_action( 'woocommerce_product_query', 'custom_shop_query' );
function custom_shop_query( $q ) {
// Check if we are on the shop page
if ( is_shop() && $q->is_main_query() ) {
$mvx_customer_follow_vendor = get_user_meta( get_current_user_id(), 'mvx_customer_follow_vendor', true ) ? get_user_meta( get_current_user_id(), 'mvx_customer_follow_vendor', true ) : array();
$author_ids = array(); // Array to store author IDs
foreach ($mvx_customer_follow_vendor as $vendor) {
$author_ids[] = $vendor['user_id']; // Collect user IDs
}
$q->set( 'author__in', $author_ids );
}
}
Leave a Reply
You must be logged in to post a comment.