add_action( 'woocommerce_order_status_completed', 'schooliner_change_role_on_purchase' );nnfunction schooliner_change_role_on_purchase( $order_id ) {nnt$order = new WC_Order( $order_id );nt$items = $order->get_items();nnt$product_id = your_product_id;nntforeach ( $items as $item ) {nnttif( $product_id == $item['product_id'] && $order->user_id ) {nttt$user = new WP_User( $order->user_id );nn $user->remove_role( 'customer' ); nn $user->add_role( 'your_role' );ntt}nt}n}