Skip to main content
added 442 characters in body
Source Link
griz
  • 194
  • 10

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 do thisactually add the role then you can use the "custom php""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.

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.

If there is no built-in action to do this then you can use the "custom php" action. 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.

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.

Source Link
griz
  • 194
  • 10

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.

If there is no built-in action to do this then you can use the "custom php" action. 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.