Hi @matteoc5,
I have some type of code for the custom post type, but it is not working can you please help? No order found.
`
function citywise_post_filter( $query ) {
if( !$query->is_main_query() ) return;
if(isset(wp_get_current_user()->roles[0]) && wp_get_current_user()->roles[0] == ‘order_manager’){
$user_id = get_current_user_id();
$zip_code = esc_attr( get_the_author_meta( ‘zip_codes’, $user_id ) );
$meta_query = $query->get(“meta_query”);
$meta_query = array(
“relation” => “AND”,
);
$query->set(‘post_type’, ‘shop_order’ );
foreach (explode(“,”, $zip_code) as $code) {
$meta_query[] = array(
‘key’=>’_billing_postcode’,
‘value’=>$code,
‘compare’ => ‘IN’,
);
}
$query->set(‘meta_query’, $meta_query );
}
return $query;
}