Badge removal automation

I often use badges to create a layer of page authentication.

I would greatly benefit from a feature that would allow badge REMOVAL as an automation when a specific form submission is completed.

3 Likes

Hi,
Absolutely! I would also love to see that feature in the Automation. My vote is in too!

Rick, I wanted to make you aware that it can be accomplished through coding in a few steps.

  1. Protect your form page with members-only permission in the page settings. (optional)

  2. Add a After Insert data hook to the form collection:
    https://www.wix.com/velo/reference/wix-data/hooks/afterinsert

  1. Add " return removeBadge ( item . _owner ) " to the hook function

import { badges } from 'wix-members-backend';

export function contact11_afterInsert(item, context) {
    await badges.removeMembers("badgeID", [context.userId])
    return item
}

If you don’t wish for the page to be accessible only to logged-in members, and to remove the badge only if a site member submits the form, then you can do so


import { badges } from 'wix-members-backend';

export function contact11_afterInsert(item, context) {
   if(context.userRole === "siteMember"){
     await badges.removeMembers("badgeID", [context.userId])
     return item
   }
   return item
}

Note: *Replace “badgeID”

Thanks. This solution does not apply to my need.

This seems like it would be easy for the Wix developers to add, but I am guessing by the lack of response in 3 months, that this whole feature request forum is not monitored.