Disabling specific form inputs

I want to disable a specific dropdown input based off the members plan type. basically, basic plan users aren’t provided access to the feature in the drop down value, so I don’t even want them to be able to click it or even see it for that matter.

How do I go about doing so?

1 Like

Just do something simple like have the dropdown list disabled on load and check the current users role or pricing plan and if it is only the basic role or plan that you are talking about, then simply have the dropdown list stay disabled, otherwise if it is any other role or plan then have the dropdown list set in code as enable so that it can be used.
https://www.wix.com/corvid/reference/wix-users.html#currentUser
https://www.wix.com/corvid/reference/wix-users.User.html
https://www.wix.com/corvid/reference/$w.DisabledMixin.html

selam

How would I CHECK the current users pricing plan? I’m looking for specific coding info like whether I should use “if,” “const,” etc. I’m clueless.

Use the Wix API references linked above to see User section which gives code on how to check current user and get price plans.

The DisabledMixin one is for showing you how to enable and disable in code, just make sure that if you disable the dropdown list element to begin with you will need to do it from the properties panel for that element.

How would I refer to the name of a plan in the coding? Is there a specific naming scheme I should follow? The name of my three plans are “Basic Plan” “Medium Plan” and “Top Tier”.

Check the api reference, the code jets the plan of the logged in user, so it basically just gets whatever you have called the plans yourself.
https://www.wix.com/corvid/reference/wix-users.User.html#getPricingPlans

Then you need to add it into your code that if there price plan is basic plan then disable the dropdown list, else if price plan anything else then enable the dropdown list.

Have a look at this previous post here and use the code as a starting point to work off of.
https://www.wix.com/corvid/forum/community-discussion/elements-show-only-for-paid-plans

This is the code I used but it doesn’t seem to work still.

$w.onReady ( function Choices() {
let user = wixUsers.currentUser;
user.getPricingPlans()
.then( (pricingPlans) => {
let firstPlan = pricingPlans[0];
let planName = firstPlan.name; // “Gold”
const Ineligible = firstPlan.name = “Basic Plan”;
if (Ineligible) {
$w(“#eventtype”).disable();
$w(“#specialrequests”).disable();
$w(“#errormessage1”).show
}
else {
$w(“#eventtype”).enable();
$w(“#specialrequests”).enable();
$w(“#errormessage1”).hide
}}
)})

Try something like this, however it may be errors in it as I have not checked for matching pairs of curly brackets and parentheses.

So you will need to go through the code to make sure that you have equal number of open { and close } and also open ( and close ).

import wixUsers from 'wix-users';

$w.onReady(function () {

let user = wixUsers.currentUser;
let userId = user.id;
let isLoggedIn = user.loggedIn;

user.getPricingPlans()
.then( (pricingPlans) => {
let firstPlan = pricingPlans[0];
let planName = firstPlan.name;

if (planName === "Basic Plan") {
$w("#eventtype").disable();
$w("#specialrequests").disable();
$w("#errormessage1").show();
}
else {
$w("#eventtype").enable();
$w("#specialrequests").enable();
$w("#errormessage1").hide();
}}
)})

I entered the code in and it definitely works. However, I am now having an issue where the disabled form elements are suddenly re-enabling as I fill in non-disabled elements.