Closed (fixed)
Project:
Privatemsg
Version:
6.x-1.0-rc3
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
22 Nov 2009 at 21:58 UTC
Updated:
14 Dec 2009 at 13:30 UTC
Hello,
I would like to integrate the privatemsg module with the userpoints API. Basically, what I am trying to reach is that everytime a messages is sent, the user sending the message will get a certain number of points.
The assistance I need is just to know if there is a hook that I can utilize in my module in order to grant point, once the private message has been successfully sent. If not a hook, then could you provide me with the information on how to do it?
Many thanks in advance. Yoel
Comments
Comment #1
berdirSure, see http://blog.worldempire.ch/de/api/group/message_hooks/1 and especially, http://blog.worldempire.ch/de/api/function/hook_privatemsg_message_insert/1. Note that author in hook_insert() (and most other hooks) is a user object, not just the uid.
Comment #2
yoeld commentedSuper! hooks_privatemsg_message_insert($message) does exactly the job
Thanks!
Comment #3
Bilmar commentedyoeld - if you could share your code for the custom module it would be very much appreciated!
thanks in advance
Comment #4
berdirYou can probably also use rules module, since userpoints does have Rules integration and privatemsg does have #327938: Rules Integration
Comment #5
Bilmar commentedTested with Rules and it worked great - allows for 'when message is sent' (however, if anyone needs, not 'when message is received').
Comment #6
igorik commentedHi
is it possible to have "when message is read" rule option ?
Comment #7
berdirWrong issue, post that to the other one (privatemsg_rules).
There is already an hook for that (hook_privatemsg_message_view), but you might want to check if the message is unread ($message['is_new'] = 1) so that you only give points when the message is read the first time... I suppose.
Comment #8
yoeld commentedAs a response for #3:
As a response for #4:
The rules can do the job, but the standard implementation of userpoint UI does not enables to add a describtion. Since it is important for my project to have a comprehensive description of the points I had to create customized functions.
Comment #9
berdirThanks for sharing your code, I've created a first version of a book page which also includes a modified version of your code, see http://drupal.org/node/646512.
Comment #10
Bilmar commentedyoeld - thank you very much!