I want to automatically change the user group to different when he spent more than for example 2000 euro in last year, but it is not working. After comunicating with your ai assistant it told be that changes are applied only after the customer login in NEXT YEAR. So the change is only created once a year in first login which is not good. Is there some possibility to change this rule so rule will be applied to customer in each customer login? Alternatively it will be ok to chcek it once a month while login but I need to use sum of orders fro last year not from last month. Can you please help me with this problem?
Thank you for purchasing B2BKing and for reaching out,
If necessary, we can help with a custom code snippet to set up a user group rule that works for your specific needs. However, I need to understand exactly how you want this to function. Could you please clarify:
1. Checking frequency: Do you want the system to check the customer's total sales from the previous 12-month period every single time they log in? For example, if a customer logs in on September 16, 2025, should it calculate their total spending from September 16, 2024 to September 16, 2025?
2. Group changes: Is this a one-time group upgrade, or do you need it to work both ways? Should customers:
- Only move UP to a higher group when they reach €2000+ (and stay there permanently)?
- Or also move BACK DOWN if their spending drops below €2000 in the rolling 12-month period?
3. Multiple thresholds: Do you have just one threshold (€2000), or multiple levels? (e.g., €1000 for Silver, €2000 for Gold, etc.)
Please be as specific as possible about these details so I can provide you with the right solution - either through configuration guidance or a custom code snippet that meets your exact requirements.
For your question number 1, I need it just how you wrote it there. I am sending you an image with group rules which I created for this. So for question number 2 I need to make it just like in image so customer can go for example from group D to group C but once he is there he can only go to group D if in last year he did not made any purchase(I made in rule condition that sum of orders from last year was less then 1 euro). So customer cannot fall for example from group A to rule B but can fall to group D. In case of any questions please ask I will try to exlain it better.
This is quite complex and B2BKing does not support it with default functionality. However, I have tried to build a custom code snippet for you for this purpose.
This should work as requested: customers can move up through groups based on 12-month spending, but can only fall back to Group D (and only when spending is below €1).
To set this up:
(1) Get your Group IDs: Go to WordPress Admin → B2BKing → Groups, click each group, and note the ID from the URL (e.g., post=123 means the ID is 123)
(2) Modify the code snippet: Replace the example IDs in the configuration section:
(replace 123, 124, 125, 126 with your real group IDs)
(3) Install: Add the code to your child theme's functions.php or use a code snippets plugin
(4) Test: Log in as a customer - the system will automatically calculate their 12-month spending and update their group
The system runs automatically on each customer login. Only completed orders count toward the spending calculation.
I want to automatically change the user group to different when he spent more than for example 2000 euro in last year, but it is not working. After comunicating with your ai assistant it told be that changes are applied only after the customer login in NEXT YEAR. So the change is only created once a year in first login which is not good. Is there some possibility to change this rule so rule will be applied to customer in each customer login? Alternatively it will be ok to chcek it once a month while login but I need to use sum of orders fro last year not from last month. Can you please help me with this problem?
Hi Radovan,
Thank you for purchasing B2BKing and for reaching out,
If necessary, we can help with a custom code snippet to set up a user group rule that works for your specific needs. However, I need to understand exactly how you want this to function. Could you please clarify:
1. Checking frequency: Do you want the system to check the customer's total sales from the previous 12-month period every single time they log in? For example, if a customer logs in on September 16, 2025, should it calculate their total spending from September 16, 2024 to September 16, 2025?
2. Group changes: Is this a one-time group upgrade, or do you need it to work both ways? Should customers:
- Only move UP to a higher group when they reach €2000+ (and stay there permanently)?
- Or also move BACK DOWN if their spending drops below €2000 in the rolling 12-month period?
3. Multiple thresholds: Do you have just one threshold (€2000), or multiple levels? (e.g., €1000 for Silver, €2000 for Gold, etc.)
Please be as specific as possible about these details so I can provide you with the right solution - either through configuration guidance or a custom code snippet that meets your exact requirements.
Kind regards,
Stefan
For your question number 1, I need it just how you wrote it there. I am sending you an image with group rules which I created for this. So for question number 2 I need to make it just like in image so customer can go for example from group D to group C but once he is there he can only go to group D if in last year he did not made any purchase(I made in rule condition that sum of orders from last year was less then 1 euro). So customer cannot fall for example from group A to rule B but can fall to group D. In case of any questions please ask I will try to exlain it better.
Attached files: group-rules.png
Hi Radovan,
Thank you for the details,
This is quite complex and B2BKing does not support it with default functionality. However, I have tried to build a custom code snippet for you for this purpose.
You can find the snippet here:
https://pastecode.io/s/fgwijzh2
This should work as requested: customers can move up through groups based on 12-month spending, but can only fall back to Group D (and only when spending is below €1).
To set this up:
(1) Get your Group IDs: Go to WordPress Admin → B2BKing → Groups, click each group, and note the ID from the URL (e.g., post=123 means the ID is 123)
(2) Modify the code snippet: Replace the example IDs in the configuration section:
(3) Install: Add the code to your child theme's functions.php or use a code snippets plugin
(4) Test: Log in as a customer - the system will automatically calculate their 12-month spending and update their group
The system runs automatically on each customer login. Only completed orders count toward the spending calculation.
Kind regards,
Stefan
Hello, Thank you for your help with this issue. I tried your code and it seems to be working just as I need.
Hi Radovan,
That's great to hear,
If you run into any issues or anything we can help with, please let us know.
Kind regards,
Stefan