0

i'm trying to create drupal 7 module for online payment , it will be by roles , for exemple ( user1 can create 'Blog content type' just if he has the permission on that) so after the payment i want to add that role to that user so i can avoid the each time creating roles for the users

thanks ^_^

0

Assuming you're using Ubercart this would be super easy by using hook_order through your own module: http://www.ubercart.org/docs/api/hook_order. I do this exact same thing with one of my other sites.

I can't go into it all, but essentially it flows like:

//make sure the order is complete and payment is received: 

function sitetheme_order($op, &$arg1, $arg2) {
{
 // on the final update check this order
 if ($op == 'update' &&
     $arg1->order_status == "payment_received" &&
     $arg2 == "completed")
 {

In order to keep this short I can't include everything, but I have short loop written that loops through the order until it meets a condition like "Tickets". Then, I'll assign a role and do some other stuff. Like:

//If they bought tickets, assign them the role "TicketHolder"
if ($node->type == 'tickets') {
  //I assign some vars, for example the ID of the user role:
   $ticketUser = $node->uid; 
   $customerRole = 16;
   //Assign this user the "TickHolder" role after the sale is complete
       $data = array(
       'uid' => $ticketUser,
       'rid' => $customerRole,
        );
   drupal_write_record('users_roles', $data);

That would be it. In your case you check to see if they purchased rights to create blog content, then assign the role.

  • tnks for the reply, in one way or another it is helpful for me ,as i understand that the Ubercart is providing some existing methods of payment,in my case i"m living in morocco and to ensure the payment it is necessarily to parse my data into a site called(maroctelecommerce.com)based for security reasons and then the site will provide the users the payment methods , after that the site will send me some encrypting post variables telling me what happened there(if the payment is success or failed ) , i'll be happy to know from you if the Ubercart give us the possibilty to do things like this – YassineEdouiri Jun 1 '13 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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