Hi all,
Is there a clever somebody who could advise on an effective solution?
At the moment I am hiding a button from members not logged in. Only logged in members can see this button.
It works fine with Js code apart from when you are logged in the button remains hidden until page is refreshed. Is there a way to code a 1 time page refresh after member logs in?
i hope that makes sense?
Thank you from your friendly neighbor hood newbie
import wixUsers from 'wix-users'; import wixWindow from 'wix-window'; import wixLocation from 'wix-location'; $w.onReady(function () { $w("#registerButton").onClick( (event) => { let email = $w("#email").value; let password = $w("#password").value; let first = $w("#firstName").value; let last = $w("#lastName").value; wixUsers.register(email, password, { contactInfo: { "firstName": $w('#firstName').value, "lastName": $w('#lastName').value, } } ) .then( (result) => { let resultStatus = result.status; wixWindow.lightbox.close(); wixLocation.to("/sign-in-status"); //Change the URL ending to whatever page you want to send the user to after they log in. } ); } ); });
How can we achieve the same refresh, but after redirecting to a new page? I want my users to land to a welcome page after sign-up (not login) which should show collection elements stored during the registration function I wrote custom. These elements appear only if I manually refreshing the page. I have a lightbox with something like $w('#SubmitButton').onClick(() => { ... wixUsers.register($w('#email').value, $w('#password').value, { // storing additional data in a custom database collection upon signup
}).then(() => { wixWindow.lightbox.close(); wixLocation.to("/signup-confirmation"); }); } The additional data I stored in the register function should be retrieved automatically and shown in the signup-confirmation page upon load, but they actually appear only after I refresh manually the page. Any idea on how I can achieve this? This is driving me mad since 3 days already, any help is super appreciated :) Thanks!
import wixLocation from 'wix-location'; $w.onReady(function () { //add an onclick here or some other event to trigger the below page refresh wixLocation.to.to(wixLocation.url); })
Thanks guys for your answers, I did find a solution however I moved to Wordpress as Wix just was not working for what I needed for memberships and for downloading documents. There were too many fixes and coding snippets for simple actions :-(
The database system was clunky as I had a 100 + downloadables. Wordpress has been my saving grace with this project and can be customised front end through plug ins. I do use wix for my other sites but found it did not Work for anything more than a simple e-commerce site sadly. That’s my experience anyway !
@bmrt82 Were you ever able to solve this issue? I am expanding some elements (Wix Video Library) on a page based on whether the user is logged in and, if so, their user roles. The code works fine except when a user is logged out and then logs in on the same page I have the expand code. I either have to refresh the page or navigate to another page and come back. I can't redirect because the code is in the onReady event. It will keep rendering. So, I would like to know if there is a way to force it to refresh the page after the login. It does not perform a refresh as expected. By the way, the page works fine if the user is on the page with the expand code and logs out. In this scenario, the page refreshes and the updates to the page are visible.
To save rendering time, I don't need to refresh the whole page. I could re-render a portion of it.
Hi mimi,
I have the same problem. How do you fix the problem?
Regards
Hi!
Usually it should by default refresh the page on promptLogin as it is loaded for the first time after the user identifies. It is strange that elements aren't loading after a login since it's the same behavior as refreshing the page.
Meanwhile as a workaround I'd suggest you to use Wix-Location .to method and target the page itself at the end of the login event.
Please share a link to your site in the comments so we'll be able to look into it.
Thanks and good luck!
Doron. :)