Login Prompt isn't working on Sign-up lightbox

Hi,

On my signup lightbox, I have a section for members to prompt them to login if they’re already members, but the code I used from Corvid API reference isn’t working.

Corvid API Reference:
https://www.wix.com/corvid/reference/wix-users.html#promptLogin

I let the code to be triggered when users click on the “Login” button.

export function loginBtn_click(event) {
    let options = {"mode": "login"};
    wixUsers.promptLogin(options)
}

Is there any limitations on how or where we can use it? Or does the API consider that I am already prompted to login but with the mode “signup”, and thus ignore the code?

If that’s the case, is there any way around to make it happen?

Thanks in advance.

So what’s the issue?

The issue is that the code refuse to run in the signup lightbox.

If you have your own lightboxes for login and signup then you don’t need to have a button for it.

On your signup lightbox you can just have a simple text element titled something like ‘Already a member? Log in’ and have that linked to your login lightbox.

Similar to the default Wix Window for signup/login where you can simply toggle between the signup and login options, instead here you are just switching between the signup and login lightboxes.

Note that Wix Users API only works fully when you are testing the website in published mode, which is stated in the Wix Users API reference.
https://www.wix.com/corvid/reference/wix-users.html
https://www.wix.com/corvid/reference/wix-users.html#promptLogin

You can see the promptLogin working in this code tutorial here.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

If you want it to be working on just a button click, then you need to code a button like this on your site.
https://givemeawhisky.wixsite.com/tagstest/blank

Make sure that if you use the Wix Members app, that you don’t have the Wix Login Bar on your site, if so you need to delete it.

Code used on page.

import wixUsers from 'wix-users';

$w.onReady(function () {
});	

let options = {"mode": "login", "lang": "en"};

export function button14_click(event) {
wixUsers.promptLogin(options)
  .then( (user) => {
    let userId = user.id;       
    let isLoggedIn = user.loggedIn; 
    let userRole = user.role;     
    return user.getEmail();
  } )
  .then( (email) => {
    let userEmail = email;         
  } )
  .catch( (err) => {
    let errorMsg = err;       
  });
}

@givemeawhisky I only have the custom Signup lightbox, and on the lightbox, there is also a button that says Login, here’s what I mean.

Yes you have already got what I mentioned above with the ‘Already a member? Log in’ text element which I can assume is already linked to your login lightbox, so that it then shows your login lightbox instead of the current signup one.

Your login button on the left hand side just needs to be linked to your login lightbox, you don’t need to be using promptLogin.

You can use the code above and still use the promptLogin, however all you are doing is opening up the lightbox for login, which is the same if you simply had the button to open the login lightbox.

https://www.wix.com/corvid/reference/wix-window.html#openLightbox

Open a lightbox

import wixWindow from 'wix-window';

$w.onReady(function () {
});

export function loginBtn_click(event) {
wixWindow.openLightbox("LightboxName");
}

I’m still using Wix Login lightbox, and I don’t have mine yet, my code in my post above does work only if I used it elsewhere, but not on an element inside the custom signup lightbox, I don’t know why it’s not working, it’s like the “Already a member? Login”, it should just open the login lightbox.

Or does it consider that the login lightbox is already opened? The text prompt in my lightbox is connected to the form data, so I don’t know what code is used to open the lighbox, but there’s defiantly a way to do it.

Okay you are using the Wix Custom window for signup where I am talking about using the Corvid option.
https://support.wix.com/en/article/about-the-member-signup-form

Although, if you click on the Log in on the Custom window, it should in theory still go to the Login window instead.

Yeah I know what do you mean, and I totally agree, in theory it should still go to the login window, but it’s not. That’s what I want to know why.

The ‘Already a member? Log in’ text link does work if you test it on a live and published website, it will not work if you try it through the preview.

It is the same with the Wix Users API, it will only work fully and properly when you are testing it in a published site and not through the Wix Editor preview.
https://www.wix.com/corvid/reference/wix-users.html

Note
The APIs in wix-users are only partially functional when previewing your site. View a published version of your site to see their complete functionality.

The APIs in wix-users can only be used once the page has loaded. Therefore, you must use them in code that is contained in or is called from the onReady() event handler or any element event handler.

On your custom signup window, you can add the login button and add the code for the promptLogin and it will work and open up the default Wix windows for login.

Although, if the user simply clicks on the ‘Already a member? Log in’, then it will simply open up the same default Wix window for login.

So, in theory you do not need any login button on your page as it is already provided.

@givemeawhisky I totally agree, I don’t need it, but I want it to work.

I’m aware of the limitations in functionalities in Preview mode, and I always have my published site on the next tab to test if everything is working as expected.

But it’s not working on the live website either