Hi!
I’m dealing now with a new issue:
I’m building a team site, all pages have members-only permissions.
I’ve built site members database in order to build users profile pages.
Now I wish to connect the username from the " member login " wix app to the title field in the site members database .
Is there a way to do it?
Thanks for your help!
Hi ft-arman.
Wanted to clarify - do you want to migrate usernames from “member login” app to a specific collection (database)?
Thanks,
Genry.
Thanks for answer Genry!
Sorry for my bad English
Exactly. I would like to migrate username or password from “member login” app to a specific collection database . That means that any user who registers on my site can write a username in addition to the insert the Email address and password .
Here’s my member profile log in page code - Private Client Member Dashboard
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
$w.onReady( () => {
if(wixUsers.currentUser.loggedIn) {
$w("#button61").label = "Logout";
$w("#button60").show();
}
else {
$w("#button61").label = "Login";
$w("#button60").hide();
}
} );
export function button61_onclick() {
// user is logged in
if(wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout();
wixLocation.to("/")
.then( () => {
// update buttons accordingly
$w("#button61").label = "Login";
$w("#button60").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("Profile")
.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("Profile", toInsert)
.catch( (err) => {
console.log(err);
} );
}
// update buttons accordingly
$w("#button61").label = "Logout";
$w("#button60").show();
} )
.catch( (err) => {
console.log(err);
} );
}
}
export function button60_onclick() {
wixLocation.to(`/Profile/${wixUsers.currentUser.id}`);
$w("#box90").hide();
$w("#vectorImage4").hide();
$w("#image165").show();
}
Thanks,
Arman.
Hi Arman.
Looks like an on demand population of the data. Does it work for you?
Regards,
Genry.
Sorry i did not understand what you said
Hi Arman.
I mean the code you posted - does it work for you?
Regards,
Genry.
Hi Genry.
Yes, it works well. When someone wants to create an account on my website, they must insert their own email address and password and their E-mail will be immediately stored in the database, Now, I want the site members, write their own username on the signup page, that their username saves in the database.
As you can see, there are only 3 fields and the username field does not exist.
I want the site members, write their own username on the signup page, that their username saves in the database.
Regards,
Arman.
Hi Arman.
Please check an existing thread about it: https://www.wix.com/code/home/forum/questions-answers/customizing-the-wix-login-page
It seems that this is not possible to customize the login page at the moment.
Regards,
Genry.
Hi Genry.
Thank you for helping and guiding anyway. 
Regards,
Arman
Just an update, you can now customize the signup page for Wix Members Areas - https://support.wix.com/en/article/creating-a-custom-signup-form-for-your-members-area
Best,
Chris
Hi everybody!
i just want to connect my database to my login website but is not working:
do i miss too connect my database som where?
import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;
import wixWindow from ‘wix-window’;
import wixData from ‘wix-data’;
$w.onReady( function () {
$w(‘#LoggIN’).onClick( (event) => {
//wixWindow.lightbox.close()
wixUsers.promptForgotPassword()
.then( ( ) => {
//
} )
. catch ( (err) => {
let errorMsg = err; //“The user closed the forgot password dialog”
});
});
});
export function loginButton_click(event) {
let Personnummer = $w(‘#PNummer’).value;
let Lösenord = $w(‘#Loord’).value;
wixUsers.login(Personnummer, Lösenord)
.then( () => {
console.log(“User is logged in”);
let
let baseUrl = wixLocation.baseUrl
https://mysite/Home); //Change the URL ending to whatever page you want to send the user to after they log in .
})
. catch ( (err) => {
console.log(err);
} );
}