Usepoints Email: An example for the new Userpoints API

AttachmentSize
Plain text icon userpoints_email.module.txt3.06 KB

Here is an example module that demonstrates how to use the new Userpoints API, currently available in 4.7.x-2.x.

This is a simple module that shows how a module can act on points gained/lost.

The site admin define a threshold of points, if it is reached, then the user will get a custom email message. The message can be customized, for example, they can get a free gift or something like that.

This module demonstrates the following:

  • Adding configuration options to the settings of userpoints.
  • Acting on points being awarded (in this case, check points, and send an email).

To actually award points in a module, you need to call the function:

userpoints_userpointsapi('points', $number_of_points, $uid, $event);

The userpoints_basic.module (part of the standard userpoints 2.0 package) demonstrates how to award points, as well as provides points for the most common actions (posting a node, posting a comment, ...etc.)

If your module provides a hook, i.e. uses module_invoke_all('modulename', ...) then you can award the points in that hook too.

Contents: 

Comments

Feature request

Please create a feature request for the userpoints project on drupal.org to add a theme function. This will allow the message to be customized.
--
2bits -- Drupal consulting