When you create a node of type Event, and it has a repeating schedule, a new node is created for each schedule date. If the event date is scheduled to repeat five times, you end up with five nodes. Userpoints does exactly what it's supposed to do - it awards points for each of these five nodes. I am looking for ideas how to get around this. I want the points to be awarded only on the first node creation. (see http://drupal.org/node/247470)

I would like to see a fifth argument to hook_userpoints where the node can be passed in. If the purpose of the 'points before' operation is to make a determination whether or not points should be awarded, it makes sense to me to have access to the node to help make that determination? If that were the case, we could do:

function yourmodule_userpoints($op, $points, $uid, $event, $node=null) {
  if ($node->eventrepeat_rid) {
    // Deny awarding the point for repeated events
    return FALSE;
  }
}

This seems to be not only the most straightforward way of handling this condition, but also the most useful.

Comments

jredding’s picture

Status: Active » Fixed

We are fixing this in version 6.x by modifying hook_userpoints to accept the entire $params array.
example

<?php
function yourmodule_userpoints($params) {
  if ($params->op == 'points before') {
    //do work, return true or false. 
  }
}
?>

Status: Fixed » Closed (fixed)

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