Forum Discussion

Claudius's avatar
5 years ago

How to access a custom user profile metadata field?

We had asked Khoros support to create as a custom profile metadata a boolean profile.receive_community_news. I am struggling to access this field via any API though. With the metadata field for messages I know that I could access them via Message.metadata calls in API v1. But I couldn't find an API v2 equivalent, nor an equivalent that works on profile metadata fields

I tried this without success ("Field 'profile.receive_community_news' does not exist for object 'settings'."):

SELECT profile.receive_community_news FROM settings WHERE user.id = '65'

How to access a custom user profile metadata field via community API? Ideally, I would like to get this setting for all members, i.e. a working API v2 call to the users collection would be my preference.

  • Claudius 

    If you want to fetch the user details from custom meta data field you can use API V1 like below 

     

    <#assign receive_community_news  = restadmin("/users/id/${user.id}/profiles/name/receive_community_news ").value>

     

     

    and for V2 you can ask support to add V2 collection for user in v2 API.

    then your API will work like below

     

    SELECT c_profile_receive_community_news FROM users WHERE id = '${user.id}'

     

     

  • I don't think api v2 supports custom fields. Hell, it doesn't even support all oob fields (I may be thinking constraints...) 😛

    If it does, though, I'd love to know as well.

    Side note, wouldn't it be in the users collection?

    SELECT profile.receive_community_news FROM users WHERE id = '65'

     

    In the past, Khoros added user metadata fields for me and I used API v1 like this:

    /users/id/${user.id}/profiles/name/metadata_field

     

    I couldn't find it the first either, so I asked support how to and they helped me with the url.