top of page

Forum Posts

keithhockaday0809
Nov 08, 2018
In Coding with Velo
Hi I set my website up for custom registration / sign up when it first went live. When you clicked on sign in button it would take you to Wix's existing user login first then the custom registration page if they clicked sign up. From last night however when someone clicks the sign in button it takes them directly to the custom registration page instead of existing user login. If they click to go to a members only page it works as it should i.e existing sign in Below is the code I use for the sign in button ; export function Login() { let options = {"mode":"login","lang":"en"}; wixUsers.promptLogin(options) } It seems like the code is bypassing the login call and going straight to the custom registration set in the members sign up settings (which i also have set to show existing member login first) Any help is greatly appreciated Thanks
0
2
58
keithhockaday0809
May 05, 2018
In Coding with Velo
Hi I am looking to be able to give access to certain pages to members who have been given admin permission in the members database however when I use the getcurrentitem query it only works if the last person who signed up has been given admin permission and not the current user. Here is the code I have been trying to use ; import wixUsers from 'wix-users'; import wixData from 'wix-data'; import wixLocation from 'wix-location'; import wixWindow from 'wix-window'; $w.onReady( () => { if(wixUsers.currentUser.loggedIn) { $w("#Login").hide (); $w("#profileButton").show(); $w("#Logout").show(); $w("#myProfile").show(); } else { $w("#Login").show(); $w("#profileButton").hide(); $w("#Logout").hide(); $w("#myProfile").hide(); } }); export function Logout() { // user is logged in if(wixUsers.currentUser.loggedIn) { // log the user out wixLocation.to('/home'); wixUsers.logout() .then( () => { // update buttons accordingly $w("#Login").show (); $w("#profileButton").hide(); $w("#Logout").hide(); $w("#myProfile").hide(); }); } } export function Login() { let userId; let userEmail; 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("Members") .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, "email": userEmail }; { // add the item to the collection wixData.insert("Members", toInsert); } (wixLocation.to(`/Members/Update/${wixUsers.currentUser.id}`)); } //navigate to profile page else { wixLocation.to(`/${wixUsers.currentUser.id}`); } // update buttons accordingly $w("#Login").hide(); $w("#profileButton").show(); $w("#Logout").show(); $w("#myProfile").show(); let admin = $w("#dataset13").getCurrentItem().admin; if (wixUsers.currentUser.loggedIn && admin === true) { $w("#fixtureUpdate").show(); $w("#upload").show(); $w("#membersB").show(); } else {if (wixUsers.currentUser.loggedIn && admin === false) $w("#fixtureUpdate").hide(); $w("#upload").hide(); $w("#membersB").hide(); } }); } export function myProfile_click() { wixLocation.to(`/Members/${wixUsers.currentUser.id}`); } export function profileButton_click() { wixLocation.to(`/Members/${wixUsers.currentUser.id}`); } everything else works great except the check admin permission any help would be very much appreciated. Thanks
0
2
78

keithhockaday0809

More actions
bottom of page