Here's my use case: I have a Paypal "Buy now" button that I have created using Paypal's Website Payments Standards utility. This provides an Instant Payment Notification when a user successfully makes a purchase.

What I would like to do is automatically give a user a role upon a successful purchase. I installed the lm_paypal module, but it is a full-featured subscription solution which I don't need; all I want to do is give users a specific role. (It's impossible to configure lm_paypal to simply give a user a role; it wants to turn the role into a subscription, but my use case is not a subscription.)

At worst, I can just add the role to user accounts manually when I receive payment, but I'd like to find a way to do it automatically.

1 Answer 1


I'm not sure the PayPal button is the way forward - you're probably better off using one of the cart modules (Ubercart, Drupal Commerce) so that when the IPN comes in the order status will be updated.

Then using Rules or Conditional Actions you can set up an event (triggered by the status update) to fire off an action that will add the role to the user.

Make sure to add conditions so that this only happens if the order balance is <= 0 (fully paid for) and if a certain product is in the cart. Also to make sure that it only occurs on updates between the two particular statuses (In Checkout -> Payment Received).

If there is no built-in action to actually add the role then you can use the "Custom PHP" action (or similar). If you find the idea of writing that chunk of php yourself, don't fret. Just search for "drupal add user role programmatically" (without quotes) and you'll be on your way. I don't know it off the top of my head, but I know that it isn't long.

One thing I have found very useful is to add an "email" action to my conditional actions, with myself as the recipient. Set the input format to PHP and put this in the body:

<?php print_r($order); ?>

This gives you the $order array from which you can extract values such as the user ID to use in your PHP action.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.