I have a dropdown that I want to hide / show certain elements based on whether the user is logged on or not. The elements are static in the dropdown. I am able to determine if the user is logged on or not.
I guess I was expecting a way to iterate each of the elements in the dropdown…
import wixUsers from 'wix-users'
$w.onReady(() => {
const currentUser = wixUsers.currentUser
const dropdownOptions = $w('#dropdown').options //Change this to your element
const notAllowedOptions = ['cheese', 'yogurt', 'milk'] //This is an example
//Create your own logic here, this is an example
if (currentUser.loggedIn === true) {
const newDropdownOptions = dropdownOptions.filter(
item => !notAllowedOptions.includes(item.value)
)
$w('#dropdown').options = newDropdownOptions
}
})