How do I make a button disappear based on who’s seeing it?
I am trying to make it so if you have already submitted something you cannot submit it again.
Or if you didn’t make a post, you can’t see a certain button.
How would I do this? Do I need to use queries?
Thanks!!
Hello Melia,
let’s do some brainstorming first.
QUESTION: What i want to do (to achieve) ?
Aim:
STEP-1: Find ID of a USER which is currently logged-in, right?
STEP-2: You will have to save the current-users input-state into DATABASE, after he has pressed a button, right? (DATA-SAVED)
STEP-3: After saving the button has to be disabled, right?
So, as you can see there are several steps to achieve your aim.
And now do it STEP by STEP…
- How to get the ID or e-Mail of the current-user?
https://russian-dima.wixsite.com/meinewebsite/user-infos
https://www.wix.com/corvid/reference/wix-users.html#currentUser
import wixUsers from 'wix-users';
// ...
let user = wixUsers.currentUser;
let userId = user.id; // "r5cme-6fem-485j-djre-4844c49"
let isLoggedIn = user.loggedIn; // true
user.getEmail()
.then( (email) => {
let userEmail = email; // "user@something.com"
} );
- How to safe USER-INPUT-DATA into database with a button-function…
https://russian-dima.wixsite.com/meinewebsite/switch-safe-function
import wixData from 'wix-data';
//------------------------------------ USER-DATA-INTERFACE -----------------------------------------
//var DATABASE = "Switch-Save-Function"
var DATASET = "dataset1"
//------------------------------------ USER-DATA-INTERFACE -----------------------------------------
var currentItemIndex
$w.onReady(function () {
$w("#"+DATASET).onReady( () => {
$w('#TXTmember').text="Member-"+currentItemIndex
$w('#BTNsave').onClick(()=>{
if ($w('#BTNswitch1').checked===true){$w("#"+DATASET).setFieldValue("btnStatus", true);}
else {$w("#"+DATASET).setFieldValue("btnStatus", false);}
$w("#"+DATASET).save();
})
$w('#BTNnext').onClick(()=>{console.log("NEXT")
currentItemIndex = $w("#"+DATASET).getCurrentItemIndex()+1
console.log(currentItemIndex)
$w('#TXTmember').text="Member-"+currentItemIndex
})
$w('#BTNprevious').onClick(()=>{console.log("PREVIOUS")
currentItemIndex = $w("#"+DATASET).getCurrentItemIndex()+1
console.log(currentItemIndex)
$w('#TXTmember').text="Member-"+currentItemIndex
})
})
});
- How to work with buttons (enable/disable/show/hide)
https://russian-dima.wixsite.com/meinewebsite/working-with-buttons
Take a look at all these examples, and after studying it for a while, i think you will be able to solve this problem by your own.
If not, you come back here 