2 replies [Last post]
Nikhil Goyal's picture
Offline
Joined: 07/13/2010
Juice: 16
Was this information Helpful?

Hello,

I want to be able to upgrade user's permission after the order status shows complete.

I figured out that I should use hook_order hook in order to achieve that. But how do I get to know which user has created that order and how do go about updating the permission.

I want this hook to be called as soon as the payment is made and the order is completed.

Any pointers will be valuable.

michaelphipps's picture
Offline
Joined: 04/22/2008
Juice: 34
Re: order complete hook and upgrade user permission/roles

I've never used this hook, but this is how I would approach it:

1) Looking at http://www.ubercart.org/docs/api/hook_order I see hook_order($op, &$arg1, $arg2)
2) Reading those docs, I see that &$arg1 holds the order object
3) I would create a test hook and do a print_r($arg1); to find out what it contained.

At the minimum I'd expect to find an order id, but quite likely the order object will contain the uid

Finally, can you use the existing roles module to achieve what you are trying to do?

Nikhil Goyal's picture
Offline
Joined: 07/13/2010
Juice: 16
Re: Re: order complete hook and upgrade user permission/roles

How can make sure that the hook is executed only when the status of the order is being changed to complete.

Sorry for such naive question, I'm still grasping the drupal module development and hooks concept. This will be my first module.