If you have subscription package in woocomerce and want to set user role according than use below code:

function supplier_change_role( $order_id ) {
  // get all the order data
  $order = new WC_Order($order_id);
  
  //get the user email from the order
  $user = $order->get_user();
    
  // if the this is a registered user and this user is not an admin
  if( false != $user && !user_can($user, 'administrator') ){
  
    // our new role name
    $role = 'woocomerce-supplier';
  
    //set the new role to our supplier
    $user->set_role($role);  
   
  }  
}
 
//add this newly created function to the thank you page
add_action( 'woocommerce_thankyou', 'supplier_change_role', 100, 1 );
Please login or Register to submit your answer

Log In

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