@schmexk
You can try this code snippet.
Select first or second add_action
depending on which WooCommerce status change you want to use.
Change $roleID = 'um_prospect';
to the role ID you want to remove from the user.
add_action( 'woocommerce_order_status_completed', 'order_complete_remove_a_role', 10, 1 );
add_action( 'woocommerce_payment_complete', 'order_complete_remove_a_role', 10, 1 );
function order_complete_remove_a_role( $order_id ){
$roleID = 'um_prospect';
$order = wc_get_order( $order_id );
$user = $order->get_user();
if ( ! empty( $user ) ) {
if ( in_array( $roleID, $user->roles )) {
$user->remove_role( $roleID );
UM()->user()->remove_cache( $user->ID );
}
}
}
Install the code snippet to your active theme’s functions.php
file
or use the “Code Snippets” plugin.
https://www.ads-software.com/plugins/code-snippets/