Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
867 B
1
Indexable
Never

$group_id = 1234;

$group_rules = get_posts([
	'post_type' => 'b2bking_rule',
  	'post_status' => 'publish',
  	'numberposts' => -1,
]);

foreach ($group_rules as $index => $rule){
	$rule_id = $rule->ID;
	$rule_who = get_post_meta($rule->ID, 'b2bking_rule_who', true);
	if ($rule_who === 'all_registered' or $rule_who === 'everyone_registered_b2b' or $rule_who === 'group_'.$group_id){
		continue; // rule applies
	}
	if ($rule_who === 'multiple_options'){
		$rule_who_multiple = get_post_meta($rule_id,'b2bking_rule_who_multiple_options', true);
		$rule_who_multiple = explode(',', $rule_who_multiple);
		if (in_array('all_registered', $rule_who_multiple)){
			continue;
		}
		if (in_array('everyone_registered_b2b', $rule_who_multiple)){
			continue;
		}
		if (in_array('group_'.$group_id, $rule_who_multiple)){
			continue;
		}
	}
	unset($group_rules[$index]);

}