Hey there,
So I have some code set up so that whenever a user is logged in, a specific page will collapse one of the inputs and change the text in the title. This specific part of the code is as follows:
import wixUsers from 'wix-users';
let user = wixUsers.currentUser;
let isUserLoggedIn = user.loggedIn;
$w.onReady((function () {
if (isUserLoggedIn) {
$w("#password").collapse();
$w("#title").text = "Sign NDA";
}
}));
This seems to be working on preview mode, but no on the live site. In live version, the page always shows the default title and expands the $w("#password") input field..
Could you please help me? What am I not seeing?
I live the total code for the page in case you need more information:
import wixData from 'wix-data'; import wixUsers from 'wix-users'; import wixWindow from 'wix-window'; import { doRegistration } from 'backend/register'; let user = wixUsers.currentUser; let isUserLoggedIn = user.loggedIn; let termsIsChecked = $w("#acceptTerms").checked; let OpportinitiesIsChecked = $w("#futureOpportunities").checked; $w.onReady((function () { if (isUserLoggedIn) { $w("#password").collapse(); $w("#title").text = "Sign NDA"; } })); function validateRequiredFields(fieldKeys) { let validationPassed = true; fieldKeys.forEach(fieldKey => { let field = $w('#' + fieldKey); if (field.validity.valueMissing) { field.updateValidityIndication(); validationPassed = false; } }); return validationPassed; } function clearFields(fieldKeys) { fieldKeys.forEach(fieldKey => { let field = $w('#' + fieldKey); if (field.type === '$w.SignatureInput') { field.clear(); } else { field.value = null; } if (field.validity.valueMissing) { field.resetValidityIndication(); } }); } export function signupButton_click(event) { if ($w("#futureOpportunities").checked) { $w("#futureOpportunities").value = "Yes"; } else { $w("#futureOpportunities").value = "No"; } const item = { firstName: $w('#firstName').value, lastName: $w('#lastName').value, email: $w('#email').value, company: $w('#company').value, position: $w('#position').value, date: $w('#date').value, phone: $w('#phone').value, acceptTerms: $w('#acceptTerms').value, futureOpportunities: $w('#futureOpportunities').value, signature: $w('#signature').value } const keys = Object.keys(item); if (validateRequiredFields(keys)) { wixData.insert('nda', item) .then((results) => { $w('#successMessage').show(); $w('#validationMessage').hide(); clearFields(keys); }) .catch((error) => { console.log(error); }); } else { $w('#validationMessage').show(); } if (user.loggedIn) { } else { let firstName = $w("#firstName").value let lastName = $w("#lastName").value let company = $w("#company").value let email = $w("#email").value let password = $w("#password").value let position = $w("#position").value let phone = $w("#phone").value; doRegistration(email, password, firstName, lastName, company, position, phone) .then((result) => { let userId = result.user.id let userInput = { "firstName": firstName, "lastName": lastName, "company": company, "email": email, "position": position, "phone": phone, "_id": userId } wixWindow.openLightbox("Confirm your email") }); } } export function signature_change(event) { $w('#validationMessage').hide(); $w('#successMessage').hide() }
As you can see in this screenshot, I'm logged in and still see the wrong title and the Password field
Hi, Annita! Could you, please, provide the site URL, so we could check it out?