How to Query a custom field in the Members/FullData collection

I am trying to create a website where each member has a unique username. I made a custom field in Contacts called “Username” and I added a custom field the the Members/FullData collection called “username”. The field id in Members/FullData is ‘custom_username’, but when I try to query it I get an error. When I query any other field that isn’t a custom field I get results.

Here’s my query function:

async function duplicateUsername(name){

const results = await wixData.query("Members/FullData").eq("custom_username",name).find();

return results.items[0];

}

Can anyone help me figure out what’s going on?

1 Like

Try getMember() instead. It will return an object with a contactDetails.customFields object and this should contain the custom_username you want as long as it is not empty.

Also not sure if you want it or not but user slugs are treated like unique usernames in Wix so you can use that as well instead of rolling your own if you’d prefer.