Members Sign Up / Login Corvid Code Not Working

Hello! I am currently in the process of coding a member sign up / log in button on a new site. I have used the same code as I have used on previous sites however this time it is not working. Please can you advise.
URL - https://stephen22477.wixsite.com/ourcoastandseas/register

I also have additional fields that users need to complete AFTER they have signed up, using the expand group, again this was working previously, however I am unable to fully test it without the login element working

The code is as follows:

import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;

var userName;

$w.onReady(function () {
setTimeout(loginCheck,200);

});

function loginCheck(){

	if (wixUsers.currentUser.loggedIn) { 
		$w("#btnLogin").label = "Log Out"; 
		$w("#group2").show(); 
		$w('#group2').expand(); 

		setTimeout(getUserInfo,200); 

	} else { 
		$w("#btnLogin").label = "Register / Log in"; 
		$w("#group2").hide(); 
		$w('#group2').collapse(); 
		$w("#txtWelcome").text = "Please click below to begin"; 
	} 

}

function getUserInfo(){

let user = wixUsers.currentUser;

wixData.query(“Delegates”)
.eq(‘_id’, user.id)
.limit(1)
.find()
.then( (result) => {

	if (result.items.length > 0) { 

		let item = result.items[0]; 

		if(item.firstName === undefined || item.firstName === ''){  
			$w("#txtWelcome").text = "Please update profile"; 
			refreshDataset(); 

		} 
		else { 
			$w("#txtWelcome").text = "Hello " + item.firstName + "!"; 
			userName = item.userName; 
		} 

	} 

}); 

}

function refreshDataset(){

var user = wixUsers.currentUser; 

var newFilter = wixData.filter(); 
newFilter = newFilter.eq('_id',user.id); 
$w("#dbDelegates").setFilter(newFilter); 

}

export function btnLogin_click(event) {
// user is logged in
if (wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then(() => {
// update buttons accordingly
$w(“#btnLogin”).label = “Log In / Sign Up”;
$w(“#group2”).hide();
$w(‘#group2’).collapse
$w(“#txtWelcome”).text = “Please click below to begin”;

		}); 
} 
// user is logged out 
else { 
	let userId; 
	let userEmail; 

	// prompt the user to log in  
	wixUsers.promptLogin({ "mode": "login" }) 
		.then((user) => { 
			userId = user.id; 
			return user.getEmail(); 
		}) 
		.then((email) => { 
			// check if there is an item for the user in the collection 
			userEmail = email; 
			return wixData.query("Delegates") 
				.eq("_id", userId) 
				.find(); 
		}) 
		.then((results) => { 
			// if an item for the user is not found 
			if (results.items.length === 0) { 

				// create an item 
				const toInsert = { 
					"_id": userId, 
					"emailAddress": userEmail 
				}; 

				// add the item to the collection 
				wixData.insert("Delegates", toInsert) 
					.catch((err) => { 
						console.log(err); 
					}); 
			} 
			// update buttons accordingly 
			$w("#btnLogin").label = "Log Out"; 
			$w("#group2").show(); 
			$w('#group2').expand(); 
    		setTimeout(getUserInfo,200); 

		}) 
		.catch((err) => { 
			console.log(err); 
		}); 
} 

}

For this site the button doesn’t go to the wix login as it did with the previous site.
Any ideas as to why?

The input elements are also showing that many are disabled in preview (which they aren’t), is this a setting in my dataset?

TIA

Hi Stephen, @thrishtilabs or @wingcc may be able to answer this question. I also recommend posting in our Corvid forum here .

export function btnLogin_click(event) {

For this line :arrow_up:
Please check that your event is set up correctly as we also easily removed (but the code stay) while using the UNDO button on the editor.

Please check this before looking at other issue

Thank you, the button onClick had changed to btnLogin_click_1

Changed now and all working!

Thank you :slight_smile:

Thank you :slight_smile: All fixed now.

Thank you @wingcc :slight_smile: