You are here

function user_badges_has_badge_by_name in User Badges 6

Same name and namespace in other branches
  1. 6.2 user_badges.rules.inc \user_badges_has_badge_by_name()

Test the user_badges_has_badge_by_name condition

File

./user_badges.rules.inc, line 188
Provide better integration into the rules module

Code

function user_badges_has_badge_by_name($account, $badgename, $settings) {
  $has_badge = FALSE;
  $user_badges = user_badges_get_badges($account->uid);
  if (count($user_badges)) {
    foreach ($user_badges as $bid => $badge) {
      if ($badgename == $badge->name) {
        $has_badge = TRUE;
        break;
      }
    }
  }
  return $has_badge;
}