Firstly, what do you mean by a ‘set period’? 30 days after signing up? Or two weeks after purchasing a product or a plan? Or on a specific date like 25th December?
Given on what your ‘set period’ is, you will either have to set up an automation or write a background cron job which:
Calculates the period and filters out members who match that criteria.
Then using the unassignBadge() function, pass the Badge ID and the ID of all the members that you want to remove the badge for.
Thank you for your reply. I speak French, so I’ll translate into English.
In Automation, I want to implement the following process:
Form submitted → badge issued to the user → 2-minute delay (for testing, for example) → badge removed.
The problem is that it gets stuck at the last step: there’s no way in Automation to remove a badge, except by using Velo code. That’s precisely where it doesn’t work. I tried using ChatGPT (https://chatgpt.com/share/6950dfcb-2e0c-8000-ae02-ebc2f6d038be) to help, but I can’t configure that part correctly.
That’s correct. Automations is indeed missing an “Unassign Badge” function. So now the only way to do this is through code, by using the function I pointed out above. All you need to do is hardcode the ID of the badge that you want to remove. If you can provide the ID of that badge, I can help you out with the code.
Thank you for your reply. Here is the ID of the badge in question. As previously mentioned, I would like the badge to be automatically removed from each person who has it, for example, 2 minutes after it is issued.
Please note that each member may receive the badge at a different time; therefore, removal must be managed individually for each user.
Finally, click on the Publish button on the top right corner to publish your automation.
Now your members’ badges will be removed automatically after the delay that you’ve set.
The automation will run individually for each user signup so yes the badge will be removed independently for each user after the set delay even if they are logged out or inactive.
Note:
To ensure this works perfectly, make sure there’s no other code, event hook or automation that will interfere with this. If you have added the code that was suggested by ChatGPT which did not work, I’d recommend that you either disable it by commenting the code, or remove it completely.