How to prevent user point totals from going below a threshold for a given user? I'd like to set an absolute floor for an individual user points (using the User Points module). Specifically, to make it impossible to have a total number of user points below 1.

In Drupal 6 there was the userpoints_no_negative module in Userpoints_contrib, but this was removed in favour of Rules integration for 7.x (https://drupal.org/project/userpoints_contrib).

The documentation provides an example using rules to evaluate point totals with a condition of "Userpoints - Compare current Userpoints"  (https://drupal.org/node/874390), but I am not finding this condition available.

I'd accept any solution, be it using rules or a custom module.



EDIT 2/4/2014 9:17PM UTC - Example code based on ramesh babu's accepted answer:

/*
 * Implements hook_userpoints().
 * Checks if points at minimum threshold, corrects to 1 if pushed below limit.
 * Based on comments in Userpoints API documentation on D.O. a separate transaction
 * is made to correct for the threshold rather than modifying the points for 
 * the existing transaction.  See https://drupal.org/node/206558
 */
function mymodule_userpoints($ops, $params) {
  if ($ops == 'points before' &amp;&amp; !isset($params['threshold'])) {
    $future_total = userpoints_get_current_points($params['uid'], 'all') + $params['points'];
    if ($future_total &lt; 1) {
      $params['description'] = 'Minimum point correction.';
      $params['points'] = abs($future_total) + 1;
      $params['threshold'] = true;
      userpoints_userpointsapi($params);
    }
  }
}


The documentation for the Userpoints API on drupal.org is also a helpful resource https://drupal.org/node/206558
Here the solution with custom module implementation:

implement hook_userpoints($op, $params) function in your custom module to check the user points in every transaction with two option called points before and points after.

For your thing check if the points are less than your threshold value, set your threshold value after the transaction.

for more referencehttp://api.worldempire.ch/api/userpoints/functions?page=1 check this.