Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
add_filter( 'woocommerce_json_search_found_customers', 'my_woocommerce_json_search_found_customers', 10 , 1 );
function my_woocommerce_json_search_found_customers ( $found_customers ) {
foreach ( $found_customers as $key=>$customer ) {
// use id to check if user is VIP
$is_a_member = false;
require_once( ABSPATH . 'wp-includes/pluggable.php' );
if ( $group1 = Groups_Group::read_by_name( 'VIP1' ) || $group2 = Groups_Group::read_by_name( 'VIP2' ) ) {
$is_a_member = ( Groups_User_Group::read( $customer->ID , $group1->group_id ) || Groups_User_Group::read( $customer->ID , $group2->group_id ) );
}
if ( !$is_a_member ) {
unset( $found_customers[$key] );
}
}
return $found_customers;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.