I am trying to implement this code using the “change email from an admin page” example. I’ve set up both the backend code and page code, and built the admin page, but am having two issues:
- The login email is not updating on submission.
- The dropdown of member data only returns 50 members - our site has several hundred. I need to be able to access all. Here’s the code I’m using:
BACKEND
import {authentication} from ‘wix-members-backend’;
export async function changeMemberLogin(memberId, newEmail) {
try {
const updatedMember = await authentication.changeLoginEmail(memberId, newEmail);
console.log(‘Member email changed’);
return updatedMember;
} catch(error) {
console.error(error);
}
}
PAGE
import { adminChangeMemberLogin } from ‘backend/change-member-email’;
import wixData from ‘wix-data’;
$w.onReady(function () {
// Only site contributors can load this data
wixData.query(‘Members/PrivateMembersData’).find()
.then((results) => {
// Restructure the returned items array so it can be assigned
// to the #memberList dropdown.
const membersList = results.items.map((member) => {
return {
label: `${member.firstName} ${member.lastName} (${member.loginEmail})`,
value: member._id
}
});
// Set the dropdown options
$w('#dropdown1').options = membersList;
});
$w('#button71').onClick(() => {
const memberId = $w('#dropdown1').value;
const newEmail = $w('#input1').value;
adminChangeMemberLogin(memberId, newEmail);
});
});