Code Access to Member Custom Fields

I am trying to access a custom field from the members table. It keeps returning Undefined, although when I try accessing the MemberID or other non-custom fields, everything works fine (thus, it is getting the member adequately.) Here is the code:

import wixMembers from ‘wix-members’;
import { currentMember } from ‘wix-members-frontend’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;

$w.onReady(function () {
currentMember.getMember({ fieldsets: [ ‘FULL’ ] })
.then((member) => {
const Org = member.contactDetails.customFields[“customfields_contact_company”].value

      $w('#text15').text = Org 
      console.log(Org) 
}) 

});


Hi,

Only custom fields added to the member profile via the Dashboard are available through the Wix Members API.

You should also be able to access Custom Fields via the contacts.getContacts() method from the Wix-crm-backend API.

I actully figured it out. It appears that the actual usage is now much more straightforward. Apparently the API has been updated without the documentation changing :grimacing:

instead of the previous:
$w(‘#text15’).text = member.contactDetails.customFields[“customfields_contact_company”].value
you can now just use:
$w(‘#text15’).text = member.contactDetails.company

Maybe this is because I declared the option

currentMember.getMember({ fieldsets: [ 'FULL' ] })




3 Likes