Untitled
unknown
plain_text
2 years ago
1.8 kB
9
Indexable
add_filter('woocommerce_account_menu_items', function($items){
// check if offers
$user_id = get_current_user_id();
$user = get_user_by('id', $user_id) -> user_login;
$email = get_user_by('id', $user_id) -> user_email;
$currentusergroupidnr = b2bking()->get_user_group($user_id);
// Define custom query parameters
$custom_query_args = array( 'post_type' => 'b2bking_offer',
'post_status' => 'publish',
'posts_per_page' => 10,
'meta_query'=>
array(
'relation' => 'AND',
array(
'key' => 'b2bking_post_status_enabled',
'value' => '1',
),
array(
'relation' => 'OR',
array(
'key' => 'b2bking_group_'.$currentusergroupidnr,
'value' => '1',
),
array(
'key' => 'b2bking_user_'.$user,
'value' => '1',
),
array(
'key' => 'b2bking_user_'.$email,
'value' => '1',
),
),
)
);
// Instantiate custom query
$custom_query = new WP_Query( $custom_query_args );
if (empty($custom_query->posts)){
unset ($items['offers']);
}
// refunds
$max_results = get_posts( array(
'post_type' => 'marketking_refund',
'numberposts' => -1,
'post_status' => 'any',
'fields' => 'ids',
'author' => get_current_user_id(),
));
if (empty($max_results)){
unset ($items['refunds']);
}
return $items;
}, 10000, 1);Editor is loading...
Leave a Comment