How to implement daily click limits and DOM removal for buttons in Webflow with Memberstack? Answered
Hey Folks!
Is it possible to remove button from DOM after it was clicked 50 times in a single day?
i have a website where user can copy json by clicking on my button, i dont want user to miss use my json, so want to limit using my button which will be removed completely from my website dom, once he click on that button 50 time in single day.
My website is on webflow and i am using memberstack plugin on my website
Comments
2 comments
Hi Mubassir,You can achieve this using custom code.The code below listens for the
DOMContentLoadedevent to ensure the script runs after the page is fully loaded. It then checks if the user is logged in via Memberstack and retrieves theclick-countfield (you would need to create a custom field in Memberstack calledclick-count) from the user's profile to track how many times the button has been clicked.When the button with the IDaddCountis clicked (assuming your button ID isaddCount), theclickCounterfunction is triggered. It increments theclickCountby 1 and updates the user's profile with the new count. If theclickCountreaches 50, the button is both disabled and hidden usingbutton.disabled = trueandbutton.style.display = 'none'. This prevents any further interaction with the button, even if the user manipulates the DOM.This setup ensures that the button can’t be clicked more than 50 times and remains hidden and non-functional after that limit is reached.I hope this helps.Thankyou so much this will work
Please sign in to leave a comment.