• Resolved lucaolgiati

    (@lucaolgiati)


    Buongiorno a tutti,

    sto usando questo codice per modificare il ruolo di un utente durante il completamento di un ordine. Funziona.

    add_action( 'woocommerce_order_status_completed', 'change_role_on_purchase', 10, 2 );
        function change_role_on_purchase( $order_id, $order ) {
            $user = $order->get_user();
            if( is_a( $user, 'WP_User' ) && in_array( 'customer', (array) $user->roles ) ) {
                $user->remove_role( 'customer' );
                $user->add_role( 'premium' );
         }
        }

    Ma avrei bisogno di un’altra funzione: l’utente cambia ruolo quando acquista 5 prodotti (al 5° prodotto acquistato il ruolo cambia) è possibile secondo voi?

    Grazie mille a tutti!!

    Luca

Viewing 2 replies - 1 through 2 (of 2 total)
  • Mirko P.

    (@rainfallnixfig)

    Hi @lucaolgiati,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    You can also visit the WooCommerce Facebook Community group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers.

    This thread has been inactive for a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Cambio ruolo utente dopo 5 acquisti’ is closed to new replies.