Skip to content

User Profile Update

js.sevestre edited this page Feb 11, 2019 · 18 revisions

User profile update

Get user Directory configuration

body = {
    "instanceId": xxx, 
    "lang": "en", # adapt 
    "type": ["user_directory"],
    "excludeType": ["community", "custom", "custom_list", "image_gallery", "menu", "news", "news_list", "page", "post"],
    "action": "CUSTOM_EDIT"}

user_directories = api.get_call(
    "content", "list", body=body, fields="cursor,items(template/components,uid)")

Each user directory has a list of fields define in user_directory.template.components.

Update the user profile

CUSTOMER_ID = 'XXX'
INSTANCE_ID = 'YYY'

api = ApiClient()

USER_DIRECTORY_ID = 'ZZZ'
USER_TO_UPDATE_EMAIL = 'me@customer.com'

userToUpdate = api.get_call('user', 'directory', 'get', email=USER_TO_UPDATE_EMAIL, contentId=USER_DIRECTORY_ID)

# To modify them, get the "uid" you want and proceed like so.
customProfileFieldToEdit1 = '1a3227d9-fa9b-4019-abf0-3525334e655f'
userToUpdate['customProfile'][customProfileFieldToEdit1] = '1990-08-15'

# To save a user in a user directory, you must add the user_directory ID in the user params.
userToUpdate['contentId'] = USER_DIRECTORY_ID

response = api.get_call('user', 'directory', 'save', body=userToUpdate)

print response['customProfile']
Clone this wiki locally