You are here

function user_badges_user_add_badge in User Badges 7

Same name and namespace in other branches
  1. 5 user_badges.module \user_badges_user_add_badge()
  2. 6.2 user_badges.module \user_badges_user_add_badge()
  3. 6 user_badges.module \user_badges_user_add_badge()
  4. 7.4 user_badges.module \user_badges_user_add_badge()
  5. 7.2 user_badges.module \user_badges_user_add_badge()
  6. 7.3 user_badges.module \user_badges_user_add_badge()

Add a badge to user.

Parameters

$uid User ID.:

$bid Badge ID.:

$type Whether set as part of the role, or individually assigned ('user', 'role').:

Return value

bool with query success

5 calls to user_badges_user_add_badge()
user_badges_add_badge_action in ./user_badges.actions.inc
Implementsa Drupal action. Adds a badge to the current user.
user_badges_change_form_submit in ./user_badges.module
Process user_badges_change_form form submissions.
user_badges_user_insert in ./user_badges.module
Implements hook_user_insert().
user_badges_user_presave in ./user_badges.module
Implements hook_user_presave().
user_badges_user_save in ./user_badges.module
Assign user badges to a user

File

./user_badges.module, line 878
@brief User Badges module file

Code

function user_badges_user_add_badge($uid, $bid, $type = NULL) {
  user_badges_user_remove_badge($uid, $bid, $type);

  // TODO Please review the conversion of this statement to the D7 database API syntax.

  /* db_query('INSERT INTO {user_badges_user} (uid, bid, type) VALUES (%d, %d, \'%s\')', $uid, $bid, $type) */
  return $id = db_insert('user_badges_user')
    ->fields(array(
    'uid' => $uid,
    'bid' => $bid,
    'type' => $type,
  ))
    ->execute();
}