I’m trying to create a members only page that will display different information based on the badge that the logged in member has. I managed to get a version of this working using Roles, but I want to work with badges instead as I can assign members badges when they register, something I can’t do with roles.
Is it possible to get the badge information when the page loads? I’ve been trying some different bits and pieces of code based on this ( https://www.wix.com/corvid/reference/wix-users-backend/badges/listmemberbadges ) but I’ve had no luck so far. Does anyone have any experience with this?
Thank you
I am going to assume you already know how to work with backend code if you are already assigning badges. If not, what code are you having trouble with? Assigning the badge or retrieving the badge? Or both?
Either way, what is the code you are using?
Post screenshots of what you have attempted so the community can help troubleshoot.
How do I make it so, if a user has a badge, a button hides or shows?
I have trouble with getting the ID of the members’ badge.
This is my code:
import { listMemberBadges } from 'backend/BuscarInsignia';
listMemberBadges([wixUsers.currentUser.id])
.then((result) => {
console.log(result);
});
// 0:"{\"memberId\":\"4c0a114b-54c6-4c03-a0db-76a02e494d4f\",\"badgeIds\":[\"0d2d9beb-65e4-4ddd-bd22-160df039e421\"]};
I only want the Badge ID, How can I get it?
@codequeennayeli