I would like to see an info operation in hook_userpoints() that returns an array describing the point events that a module exposes. This would allow much further extension of the userpoints module, by other contrib modules, as well as providing better information to the user. For instance:

return array(
  'userpoints_post_comment' => array(
    'title' => t('!Points for posting a comment', userpoints_translation()),
    // we could have other options here like a descriptive user message, default values, etc...
  ),
);

Specifically what I am trying to achieve is a way to cap individual point events, for instance, posting a user is only rewarded for posting a blog the first 5 times. This can already be done using 'points before', but the admin interface would prove to be tricky, since there is no way to know (ahead of time, anyway) which point events are available.

I would be happy to do the development on this, but would like to hear from the maintainers before I put too much time into it.

Comments

kbahey’s picture

Version: master » 6.x-1.x-dev

This was part of my original vision for the module. The idea was to have a registry of the operations that would award points, so we can query them all, rather than have ad hoc free form text fields.

But, please coordinate with jredding, because he is planning to do major work on the D6 version of userpoints. Of course we need to review and discuss the patches you provide in detail before they get in the code.

jredding’s picture

whoo hoo, I'm excited for this! Can we collaborate over at http://groups.drupal.org/user-points

I'm currently working on some fairly major changes to the Drupal 6 structure (mainly backend type stuff, outlined over at g.d.o). I have time this week and next week to get it all done so if you're up for working on this lets coordinate and crank it out!

zroger’s picture

sounds great. see ya on g.d.o

jredding’s picture

any update on this? the new hook_userpoints passes the entire $params array thus the hook is now

function mymodule_userpoints($op, $params) {
  if ($op == 'setting') {
  }
}

in short the road has been paved now we just need a bit more clarification/direction

zroger’s picture

i haven't had any time lately to work on this, but I can dive back into it next week. I'm very interested to see the latest enhancements.

berdir’s picture

I like this idea and I'll probably start working on this...

Advantages I see:

- Display an overview of actions that a user can points with.
- It can help to avoid storing translated texts (like description, operation, ...) in the database and instead just have a reference to the action. Would solve a bunch of multi-language issues.

Won't be easy, though :)

berdir’s picture

Status: Active » Closed (duplicate)

7.x now has hook_userpoints_info().