1. Is there a way to assign certain default number of points for each new user?
2. how can i add/subtract certain number of points to all existing users?
Currently it seems I need to do this manually by adding points for each individual user

CommentFileSizeAuthor
#4 userpoints_register.tar_.gz1.78 KBtom_o_t

Comments

kbahey’s picture

Status: Active » Fixed

You can easily write a module to do these things.

Here is some example code:

For the first requirement, you would use hook_user() like this:

function yourmodule_user($op, &$edit, &$account, $category = NULL) {
  switch($op) {
    case 'insert':
      $params = array (
        'uid' => $account->uid,
        'points' => 5,
      );
      userpoints_userpointsapi($params);
      break;
  }
}

For the second point, you use something like this:

// Query for all users, perhaps those that are not blocked
$result = db_query("SELECT uid from {users} WHERE status = 1");
while($data = db_fetch_object($result)) {
       $params = array (
          'uid' => $data->uid,
          'points' => -5,
          'moderate' => FALSE,
          'event' => 'penalty',
          'display' = FALSE,
          'description' => t('Penalize everyone on the site, just because the admin feels like it'),
        );
        userpoints_userpointsapi($params);
}
xjs’s picture

Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

tom_o_t’s picture

Version: 5.x-3.x-dev » 6.x-1.x-dev
Category: support » feature
Status: Closed (fixed) » Needs review
StatusFileSize
new1.78 KB

Addressing #1 above, attached is a simple module to do this - I created it for Sony Music

Users receive a configurable number of userpoints for registering (creating an account).

I'm happy to tweak as necessary to get this into the userpoints contrib module - just let me know.

kbahey’s picture

Status: Needs review » Fixed

Thank you for this. Committed.

Should be in the 6.x-1.x-dev tarball in 6 or so hours.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.