Hello! I have the following question: when a customer's user role is changed - manually or automatically - does he get a message? (Email) Can I set this up? Thank you and greetings! Wolfgang
Just for clarity, I mention our plugin doesn't use WP roles (such as 'subscriber', 'administrator', 'editor' etc). Our plugin uses its own groups instead.
Users would not normally get a message when their group is changed.
That's because groups are not really 'public' by default (they're more of a private way for the admin to organize users, it shouldn't necessarily be visible or known to the user).
We may be able to write a code snippet that does that, but it is quite complex. Can you give us more information about what you are trying to set up or achieve in your store? I wonder if we have a different way of doing it or some simple way of setting this up,
Hello! When a customer has multiple orders or reached a certain amount, then I want to automatically change their user role from "Customer" to "Regular Customer" with 5% discount. Of course, the customer should be informed about this by e-mail. According to the motto: "Congratulations! From now on you are a regular customer and get 5% discount on every item!"
1) Go to B2BKing -> Group Rules and configure a group rule based on "TOTAL SPENT", for example:
2)
Add this PHP code snippet to your site:
add_action('b2bking_apply_group_rule', function($rule_id, $howmuch, $newgroup, $user_id){
$email_sent = get_user_meta($user_id,'group_email_sent', true);
if ($email_sent !== 'yes'){
$user = new WP_User($user_id);
$condition = get_post_meta($rule_id, 'b2bking_rule_applies', true);
if ($condition === 'order_value_total'){
$total_orders_amount = $user->get_total_spent();
if ($total_orders_amount >= $howmuch){
$recipient = $user->user_email;
$message = 'Congratulations! From now on you are a regular customer and get 5% discount on every item!';
do_action( 'b2bking_new_message', $recipient, $message, get_current_user_id(), 0 );
update_user_meta($user_id,'group_email_sent', 'yes');
}
}
}
}, 10, 4);
Hello! I have the following question: when a customer's user role is changed - manually or automatically - does he get a message? (Email) Can I set this up? Thank you and greetings! Wolfgang
Hi Wolfgang,
Just for clarity, I mention our plugin doesn't use WP roles (such as 'subscriber', 'administrator', 'editor' etc). Our plugin uses its own groups instead.
Users would not normally get a message when their group is changed.
That's because groups are not really 'public' by default (they're more of a private way for the admin to organize users, it shouldn't necessarily be visible or known to the user).
We may be able to write a code snippet that does that, but it is quite complex. Can you give us more information about what you are trying to set up or achieve in your store? I wonder if we have a different way of doing it or some simple way of setting this up,
Kind regards,
Stefan
Hello! When a customer has multiple orders or reached a certain amount, then I want to automatically change their user role from "Customer" to "Regular Customer" with 5% discount. Of course, the customer should be informed about this by e-mail. According to the motto: "Congratulations! From now on you are a regular customer and get 5% discount on every item!"
Hi Wolfgang,
To achieve that, you can:
1) Go to B2BKing -> Group Rules and configure a group rule based on "TOTAL SPENT", for example:
2)
Add this PHP code snippet to your site:
A PHP snippet can be added to functions.php, or by following our guide here: https://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/
It should then automatically send the message configured in the snippet to the user when they get promoted to the new group.
Kind regards,
Stefan
Hello Stefan,
thank you very much!
I have it set up now and will report if it works.
Thanks again - Wolfgang