I created a custom database (owners) and linked the data by email. The custom link works when the user manually adds their data. When I import the data the link using the email does not work. If the user manually adds their data I have two records in the owners table.
My code on my login page looks like
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
$w.onReady( () => {
if(wixUsers.currentUser.loggedIn) {
$w("#login").label = "Logout";
$w("#profile").show();
}
else {
$w("#login").label = "Login";
$w("#profile").hide();
}
} );
export function login_click() { // user is logged in if(wixUsers.currentUser.loggedIn) { // log the user out wixUsers.logout() .then( () => { // update buttons accordingly $w("#login").label = "Login"; $w("#profile").hide(); } ); } // user is logged out else { let userId; let userEmail; // prompt the user to log in wixUsers.promptLogin( {"mode": "login"} ) .then( (user) => { userId = user.id; return user.getEmail(); } ) .then( (email) => { // check if there is an item for the user in the collection userEmail = email; return wixData.query("Owners") .eq("_id", userId) .find(); } ) .then( (results) => { // if an item for the user is not found if (results.items.length === 0) { // create an item const toInsert = { "_id": userId, "email": userEmail }; // add the item to the collection wixData.insert("Owners", toInsert) .catch( (err) => { console.log(err); } ); } // update buttons accordingly $w("#login").label = "Logout"; $w("#profile").show(); } ) .catch( (err) => { console.log(err); } ); } } export function profile_click() { let user = wixUsers.currentUser; let userId = user.id; // "r5cme-6fem-485j-djre-4844c49" let isLoggedIn = user.loggedIn; // true let userRole = user.role; // "Member" user.getEmail() .then( (email) => { let userEmail = email; // "user@something.com" wixLocation.to("/Owner-Database/"+userEmail); } ); }
As I said the "profile_click" is working and bring the user to their page, but it does not seem to be linking on the email address as the user has data in the owners database but comes up blank when the user opens their profile
Hi,
ill forward your question to the relevant team in Wix
Shlomi