• Resolved irwinrouch

    (@irwinrouch)


    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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author eliasatcluevo

    (@eliasatcluevo)

    Hi there,

    thank you for reaching out.
    The CLUEVO WooCommerce API premium extension actually does exactly what you are describing. Adding CLUEVO Groups to users when the purchase a product via WooCommerce.
    If you have any questions regarding premium extension, please use our official support channels for CLUEVO Premium products under: https://wp-lms.cluevo.at/ -> support -> contact

    Best regards,
    Elias

    Thread Starter irwinrouch

    (@irwinrouch)

    Thank you for the answer. Very clear. I was hoping for a free workaround as for now, I have no visibility or future purchase, But I will manage manually first until volume gets too high.

    Cheers,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Link Worpress usergroup to Cluevo user Group’ is closed to new replies.