I’m implementing a custom member area, and since all Wix apps use member data like name and profile photo from the default Wix Members data collection, I need to ensure member information is updated in both the default and custom members data collections.
To do this, I’m using the updateMember() function from wix-members-backend, which works well for most fields—except the profile photo. The Wix Members Backend API doesn’t explain how to update the profile photo specifically, but I was able to find the required format by checking the output of the currentMember() function through console.log()
below is the current code
$w("#professionalUpdateButton").onClick(async () => {
const professionalMembersDataset = $w("#professionalMembersDataset");
try {
// Save the dataset which automatically updates the fields connected to the dataset
await professionalMembersDataset.save();
// Retrieve the updated data from the dataset
const updatedData = professionalMembersDataset.getCurrentItem();
// Prepare memberData with values from the saved dataset item
const memberData = {
contactDetails: {
firstName: updatedData.firstName,
lastName: updatedData.lastName,
},
profile: {
nickname: updatedData.nickname,
profilePhoto: {
url: updatedData.photo,
}
},
};
// Get the current member ID from the dataset
const memberId = updatedData._id;
// Call the backend function to update Wix Members system data
const response = await myUpdateMemberFunction(memberId, memberData);
// Show success message if update was successful
if (response && response.status === 200) {
console.log(
"Member data updated successfully:",
response.updatedMember
);
$w("#updateSuccessMessage").text = "Your content has been updated.";
$w("#updateSuccessMessage").show();
setTimeout(() => {
$w("#updateSuccessMessage").hide();
}, 5000);
} else {
throw new Error("Failed to update member in Wix Members system.");
}
} catch (err) {
console.error("Error updating member data:", err);
$w("#updateErrorMessage").text =
"An error occurred while updating member data.";
$w("#updateErrorMessage").show();
setTimeout(() => {
$w("#updateErrorMessage").hide();
}, 5000);
}
});
As you can see, I’m setting profilePhoto.url to the field containing the photo. However, when I try to reference the field that holds the uploaded profile image, such as:
• updatedData.photo.src
• updatedData.photo.url
• updatedData.photo.fileUrl
… none of these seem to work. Manually inserting a URL like “https://example.image.png” works fine, so I believe it’s an issue with accessing the correct URL format for the uploaded image.
If anyone has insights or a solution, I’d greatly appreciate the help