Hello. I’ve had a somewhat similar problem before where authentication.register() wasn’t saving birthdates. I’ve just rechecked my site and now it seems it’s not saving ANY custom field when called. Docs say passing an object containing additional user data in the third argument should work but it’s not.
below is my register function
export async function doRegistration(email, pw, payload) {
const { contactInfo, page, birthdate } = payload
const resOptions = {
contactInfo,
}
//create label array
const labelKeys = ["label 1"]
//add labels based on registration answers
if(contactInfo["custom field 1"] == "yes") {
labelKeys.push("label 2")
} else {
labelKeys.push("label 3")
}
if(contactInfo["custom field 2"] == "yes") {
labelKeys.push("label 4")
}
resOptions.contactInfo["labels"] = labelKeys
console.log("registration object being passed: ",resOptions)
try {
// resOptions looks like: {"contactInfo:{"firstName":"test","lastName":"test","birthdate":"2022-10-01","customFieldNoSpace":"test","custom field 1":"yes","custom field 2":"yes","labels":["label 1","label 2","label 4"]},}
const res = await authentication.register(email, pw, resOptions)
console.log("register success", res)
// send confirmation email
await triggeredEmails.emailMember('confirmationEmail', res.member._id, {
variables: {
confirmUrl: `url?tk=${res.approvalToken}&pg=${page}`,
tk: res.approvalToken,
pg: page,
}
})
return res
}catch (error){
console.error(error)
return error.message.toString().includes("already exists") ? "Email already exists" : error.toString()
}
}
when I check in contacts, the only thing that’s stored is the user’s name and email. none of the additional details is saved.
Am I passing the wrong key:value pairs? Is it expecting something similar to the contacts API where custom fields are under an extendedFields key? My code was working as until the end of September. I noticed many new users did not have any custom field values.