How to change user role after subscription
You may use "WooCommerce Subscriptions" plugin and "Ultimate Member - WooCommerce" extension to change user role after subscription.
Install plugin "WooCommerce Subscriptions" and create product with type "Variable subscription" and some variations. Also you may use "Simple subscription" product type.
Go to the admin page "User Roles" and click to the button "Add New" - you will see "Add New Role" form. Create and configure role "Member" (for example), pay attention to the metabox "Registration Options". Set options:
- Registration Status = "Auto Approve"
- Action to be taken after registration = "Redirect to URL"
- Set Custom Redirect URL => Link to the product with type "Variable subscription" that was created before.
Go to the "Edit Form" page for the Registration form, pay attention to the metabox "Registration Options". Set options:
- Apply custom settings to this form = "Yes"
- Assign role to form = "Member"
- Primary Button Text = "Register"
If you don't want the user to have to fill in all of the Woo checkout info you should add these fields to the Registration form. UM has predefined fields that equals to WooCommerce fields:
- WC Billing First name (required)
- WC Billing Last name (required)
- WC Billing Company
- WC Billing Address 1
- WC Billing Address 2
- WC Billing city
- WC Billing postcode
- WC Billing country
- WC Billing state
- WC Billing phone
- WC Billing email (required)
- WC Shipping First name
- WC Shipping Last name
- WC Shipping Company
- WC Shipping Address 1
- WC Shipping Address 2
- WC Shipping city
- WC Shipping postcode
- WC Shipping country
- WC Shipping state
- WC Shipping phone
- WC Shipping email
Go to the settings page for the "Ultimate Member - WooCommerce" extension. Set options:
- Remove previous roles when change role on complete or refund payment = "Yes"
- Do not update these roles when payment is completed = "Administrator"
Path: menu "Ultimate Member" > submenu "Settings" > tab "Extensions" > subtab "Woocommerce".
Return to the product with type "Variable subscription" that was created before, pay attention to the metabox "Ultimate Member". Specify roles for the all states of subscription. In the most common case it should be:
- When subscription is ACTIVATED move user to this role = "Subscriber"
- When subscription is PENDING move user to this role = "Subscriber"
- When subscription is ON-HOLD move user to this role = "Member"
- When subscription is EXPIRED move user to this role = "Member"
- When subscription is CANCELLED move user to this role = "Member"
- When subscription is PENDING-CANCEL move user to this role = "Member"
See example of the registration and subscription process:
Redirect to the subscription product page after registration
Cart (this step depends on WooCommerce settings)
* User roles after registration
* User roles after subscription complete
* User subscriptions