Possible to enable/disable a checkbox based on membership Answered
It's simple enough to hide a checkbox to non-members using data-ms-content, but I would like to show the checkbox and have it be disabled for non-members (with an onClick action to prompt for upgrade).
Is this possible? Thanks
Comments
6 comments
Hey Samuel 👋
Great question. I think this may be doable. I would set everything up with the checkbox disabled and get it working as you want and then use the DOM package which is in the Webflow package to get the member and remove the disabled attribute on the checkbox. This article should get you on the right path.
Thanks for this! I'll have a go
OK, this worked pretty well so thanks for this. But then it got me wondering, because this is secured client-side, someone could just edit the script to remove this check.
Equally someone could remove the 'data-ms-content' span, and see hidden functionality of the site they aren't supposed to, right?
You are correct. There is not a 100% safe way to do something like you are doing because it is all in the front-end. That being said you could add this code to make javascript required to view the page.
Samuel Taylor Would you mind sharing that code you used to disable the checkbox?
Also, if you're worried about content security I recommend reading this new article I wrote. It's 4 steps you can take to make your site as secure as Google photos. https://docs.memberstack.com/hc/en-us/articles/7979946671131
I decided to drop WebFlow and use a full-stack solution from elsewhere as I realised I was trying to make a front end product for static sites do a job it's not suited for!
Please sign in to leave a comment.