How can i make the wix member log in screen show when a button is clicked?
I have a "Login" button i have designed but need the wix member popup to show once clicked, how can i do this? I have tried but keep getting error messages with the code. Help! :)
Ok, a few things.
First, the to( ) function expects a string, so you need to enclose the URL in quotes.
Second, looks like your linking to a page in the same site. If that's the case, you can use just a relative URL as described in the API Reference. (Using the full URL should work too.)
Third, the login might not "work" anymore because you are already logged in. If you're already logged in, it will skip the login popup. You can add a logout button using wixUsers.logout( ).
It doesn't seem to work...the login pop up wont work now either?
It should be something like this:
import wixUsers from 'wix-users'; import wixLocation from 'wix-location'; export function button1_onClick(event) { wixUsers.promptLogin() .then( () => { wixLocation.to(URL_GOES_HERE); } ); }
I can't seem to get this to work either! haha
You can use the "then" to perform an action after the login is successful. Right now, the code you copied pulls a bunch of the user info and doesn't do anything with it. You can delete that if you don't need it. In its place use the wix-location .to( ) function to navigate to a URL.
Thanks so much Sam, you have been amazing as always! :)
OMG IT WORKS!!!!!!!! Simple things like this could surely be helped? Would be cool if it told us where to place it if there was an error, however, that's for another year...! lol
Okay, would you be able to help me with the next request i have? It should be simple, how can i point that to go to a URL when successfully logged in?
I can't actually get into your site right now. But judging from my browser console when I visit your site, it looks to me like you just moved the word "import" up out of the event handler. You need to take the whole line
import wixUsers from 'wix-users';
and move that up.
Still not working Sam, it's now showing more error messages. This is the site
https://ignitecreativedesign.wixsite.com/mysite-11
Try pulling the import statement out of the onClick event. Put it all the way at the top of the page code.
Wow - that was quick, i have tried implementing this but it's not doing anything on click?
Hi Robert,
You want to use the wix-users promptLogin( ) function in the onClick event handler of your button. Is this what you've tried? What error messages are you getting?