Custom Login

@patbensky You dont have to have to link it to a sign up form. All you need to do is link to your login.

Let me give you a link to a video tutorial where I explain how to make a private registration page to avoid people from signing up. You still need a sign up form somehow ---- but it needs to be privately controlled by you. If you dont ---- then you will never be able to create new users to login using your custom login. (Adding users to you CRM contact list does not enable them nor creates permission for them to login.)

Tutorial video:

I still was not able to get it to work correctly so I started from scratch again, following Nayeli’s tutorial precisely.

The custom login lightbox opens when you click Login or Bylaws, but it does nothing when you click the Log In button.

I’ve created a test user with email: test@catbase.com and password: password if you care to try it :slight_smile:
https://csmc77.wixsite.com/

Maybe this is relevant … there is an error message in my page code which I can’t get rid of:


There is no element on the page called “userPassword” and there is no mention of it within the code.

Here’s my code:


import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;
import wixWindow from ‘wix-window’;
$w.onReady( function () {
$w(“#forgotPassword”).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 email = $w(“#email”).value; // “email” is the email field in the Members collection and the ID of the email input
let password = $w(“#password”).value; // “password” is the name of the pw field in the Members collection and the ID of the pw input
wixUsers.login(email, password)
.then( () => {
console.log(“User is logged in”);
wixLocation.to(“/home”);
} )
. catch ( (err) => {
console.log(err);
$w(“#errorMessage”).expand();
}


Another thing which I feel may be relevant is that I am using a custom Collection to manage the members data, not the default “Privatemembersdata” collection. Do I need to specify this somewhere?

Many thanks, once again, for any help you can offer!

Pat

@patbensky I think you are still confused about what the custom login actually does. Let me try and break it down for you again …

Wix allows you to create page permissions so that pages are accessible by public visitors, paid subscribers or non paying members.

Wix knows who is who by allowing a user to log into your website. A user can either login using the native Wix Login window or from a custom coded login window you create on your own. In order to login using a valid email and password, a user must first be registered to your website.

When you register a new user, they get added to your wix CRM / USERS. To register a new user you can either use the native Wix Registration window or create your own via code. Wix CRM / USERS does not read custom database collections for the page permissions nor for logins. (This is why the code starts with import wixUsers) You cannot manually add members via your Wix Contact list. They have to be registered one of the two ways mentioned above.

( Please note ---- it is bad practice to save email and password in a custom database collection. )

Regarding your errors. If the user does not exist as a registered member, then they wont be logged in. If you don’t have an error text message on your page, then your code won’t display that an error happened during login attempt. If you do have an error text message on your page then make sure the code matches the properties panel settings of the text element (show / hidden on load …or expand / collapsed on load) If there are any red errors on blank lines, try deleting all blank lines by using the backspace.

Earlier, a video tutorial link was shared with you. This tutorial explains how to create a private dashboard page that only Admins access via their Wix Dashboard. This page allows the Admin to create a new user by saving an email and password to the Wix CRM / USERS. Here is that link again:

To recap: In order to login, your user first has to exist in the Wix CRM / USERS.

@code-queen Thank you for the explanation.
So just to be clear:

If I want to manage custom fields for my members then I need to create a Collection. I created a collection called Members.

But if I want those people in my Members database to also have a login for the site, then they must ALSO be separately registered as site users using the Wix CRM/Users.

So … How do we link the two together? So that if a registered user logs in, their Member details are selected and they can view/modify them?

Thank you for your patience with me, and for your detailed and thoughtful replies.

Pat

hey , looking for to get a option for login via phone number

Please add your own issue into a new post instead of bumping up an old post. Explain what you are trying to do, what works, and what doesn’t. Also, add any code in a code block as stated in the Forum Guidelines .

See the article Creating the Member Signup and Login Forms . If you don’t see the options that you want, feel free to make your voice heard. The Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.

This is an old post and is being closed.