Identifying User

Hi there,

In order to fetch the value of the custom fields, you do not need to query the user’s info using wix-crm. You can directly do it from the frontend using the wix-members-frontend API, by setting the fieldsets to “FULL”

Take a look at the code I’ve provided below:

import {currentMember, authentication} from 'wix-members-frontend';

$w.onReady(async function() {

    const isLoggedIn = authentication.loggedIn();

    if (isLoggedIn) {

        let options = {
            fieldsets: ['FULL']
        }

        let member = await currentMember.getMember(options);

        if (Object.keys(member.contactDetails.customFields).length > 0) {

            let value = member.contactDetails.customFields['custom.usertag'].value;

        } else {
           // Handle case if user does not have any custom fields added to their profile.
        }

    } else {
        // Handle case if user is not logged in.
    }

});

Just change usertag to the key of your custom field, and you’re good to go!