Opening the default wix-members login lightbox by the JS code

I want to open the default login form (lightbox) by the custom button click handler, that is described in the page’s code.
I do not want to create the custom login lightbox, i’m already satisfied with the default login lightbox, provided by the wix-members package.

How can I do that? Or is it possible at all? I couldn’t find any solution in the wix-members documentation or in the support forums.

1 Like

Maybe you first want to describe what you already have done?
You surely already did some setups ?

I want to open the default login form (lightbox) by the custom button click handler, that is described in the page’s code.
In which page’s code?

Here’s the default wix-members login modal


I have a public page, with button. If user is logged in, clicking on button will open the modal with subscription. If user is not logged in, I want to open the default login modal, that is shown above.

Here’s the code example:
$w . onReady ( async () => {
wixMembers . currentMember
. getMember ()
. then (( member ) => {
$w ( ‘#repeater1’ ). data = [
{
_id : uuidv4 (),
openSubscriptionModal : buyOneMonthSubscription ,
sum : 300 ,
title : ‘monthlySubscription’ ,
},
{
_id : uuidv4 (),
openSubscriptionModal : buySeasonSubscription ,
sum : 800 ,
title : ‘seasonSubscription’ ,
},
]

        $w ( '#repeater1' ) 
            . onItemReady (( $item ,  itemData ) => { 
         // Here's the handler, I'm talking about 
                if  ( member ) { 
                    $item ( '#payBtn' ). onClick (() =>  itemData . openSubscriptionModal ( member )) 
                } 
                // if member is undefined (user os not logged in) open the default wix-members login modal 
                // $item('#payBtn').onClick(() => { somehow open login modal }) 
            }) 
    }) 

})

To go your own custom-way, you will have to setup your LOGIN as → individual/custom-mode…

The shown pic will show you all options given by wix.

In your case, you will have to choose the “individual-one” → custom-mode.


You will also get a new lightbox…

Ok, understood. So I can’t use the default login lightbox.

Thanks for help!

You can use the following code where it is neccessary to get default login lightbox opened.

// Import Wix Users
import wixUsers from 'wix-users';

// Call following function where we need to open Lighbox.
wixUsers.promptLogin();