You can automatically assign user roles to customers when they buy certain products. For example, if you are selling memberships to your site, you can create a ‘Gold Member’ product that assigns the ‘Gold Membership’ user role to anyone who purchases it.
For guidance on setting user roles after purchasing a product, take a look at this article.
Assigning roles on order completed
By default, the new role will be assigned to the user when their order status changes to ‘Processing’. This ensures that users don’t get their new roles too soon.
However, some orders might skip the ‘Processing’ status, e.g. orders containing downloadable products. In this case, you can set the status where roles are assigned to ‘Completed’.
To do this, go to WooCommerce > Settings > Members Only > Registration and choose ‘Order Completed’ from the ‘Assign Roles Order Status’ field.