You can disable points for specific user roles by adding below code to functions.php:
add_filter('wpgens_loyalty_should_allow_points_for_user', 'filter_points_by_user_role', 10, 5);
function filter_points_by_user_role($should_allow, $user_id, $source, $type, $points_delta) {
// Define roles that should be excluded from points system
$excluded_roles = ['wholesale'];
// Get user object
$user = get_userdata($user_id);
if (!$user) {
return $should_allow; // User not found, keep default behavior
}
// Check if user has any excluded roles
$user_roles = (array) $user->roles;
$has_excluded_role = array_intersect($user_roles, $excluded_roles);
if (!empty($has_excluded_role)) {
WPGL_Logger::points("Points update blocked for excluded role", [
'user_id' => $user_id,
'user_roles' => $user_roles,
'excluded_roles' => $excluded_roles,
'points_delta' => $points_delta,
'source' => $source
]);
return false; // Block the points update
}
// Allow points update to continue
return $should_allow;
}