I am setting up a membership using the Toolset documentation provided.
I have different levels of membership so I created different levels using Access: Premium, Basic, Standard
When I attached the subscription product to the user Form it creates only users of the type Subscriber. This is a setting that is set in Woocommerce.
The User form created in Toolset should create users with types of: " Premium, Basic, Standard"
Is there a way to over ride the Woocommerce setting to use the Toolset user forms?
add_action( 'cred_commerce_after_order_completed', 'func_set_custom_role', 10, 1 );
function func_set_custom_role( $data ) {
// check for a specific form
if($data['extra_data'][0]['cred_form_id'] == 99999) {
$user_id = $data['user_id'];
$user = new WP_User( $user_id );
// Remove role
$user->remove_role( 'subscriber' );
// Add role
$user->add_role( 'your-role-slug' );
}
}
Where:
- Replace 99999 with your original form ID.
- Replace 'your-role-slug' with your original role slug.
- You are welcome to adjust the code as per requirement based on your different product IDs and set different role as required.