Link Worpress usergroup to Cluevo user Group
-
Hello,
I looked in the forum and only found a 2 years ago post saying it was not possible but part of the future features for the plugins.I would like when a user gets the X role in Worpress it automatically gives the Y role in Cluevo.
I guess a PHP function could do this but I am not really familiar with thos functions and how they work.
I already have this code that enables people who purchase a specific woocommerce product to add to “customer” role another one “Cluevosuperuser”…in worpress user management role.
Could I adapt it so that the role is in cluevo instead or add a function that adds a secific cluevo role based on wordpress role ?
/** * Snippet Name: WooCommerce Change User Role After Purchase * Snippet Author: ecommercehints.com */ add_action( 'woocommerce_order_status_completed', 'ecommercehints_change_user_role_after_purchase' ); // Order Status must be Complete function ecommercehints_change_user_role_after_purchase($order_id) { $order = wc_get_order( $order_id ); $items = $order->get_items(); $eligible_product_ids = array( '128', '31', '69' ); // Only change if any one of these product IDs are in the order foreach ($items as $item) { if ( $order->user_id > 0 && in_array( $item['product_id'], $eligible_product_ids ) ) { $user = new WP_User( $order->user_id ); $user->add_role( 'Cluevosuperuser' ); // The new role is added break; } } }
Thanks a lot
- The topic ‘Link Worpress usergroup to Cluevo user Group’ is closed to new replies.