The following code was tested… and works like it should…
$w.onReady(()=>{let counter = 0;
let btnAccept = $w('#btnCvCreationTool');
btnAccept.onClick((event)=>{
console.log(event.target.id+"-clicked-"+counter);
counter = counter +1;
if (counter >=5) {btnAccept.disable();}
else {btnAccept.enable();}
});
});
As we can see inside the console, i was able to click only 5-times onto the button, until the button had been deactivated…

That was my testing button, somewhere on one of my running projects…

After 5-clicks it got disabled…

Of course your button will be REENABLED again, if you …
---------------> REFRESH THE PAGE <--------------
And now you should think about a database → which saves all the clicks of each users, who visits your site.
-
User-A visit your site and clicks 4-times, before leaving your page.
-
User-B visit your site and clicks 3-times, before leaving your page.
-
User-C visit your site and clicks 5-times, before leaving your page.
All of this users, would automaticaly refresh the button, and the button would work again and again, if you do not save the current state of the button for each of the users.
But how to do? What do you need to achieve such functionality?
-
First you should be able to get the ID of current user.
-
You should be able to get the amount of clicks of current user.
-
You should be able to save the current amount of clicks to your DB for each user.
-
You should be able to load the data for each user automatically when the page gets ready (including your BUTTON).
What would be the code-flow…
-
User logs in —> you get his ID
-
Now when you know users ID → loading the data of this user including the AMOUNT of CLICKS, from your DATABASE.
-
Running an IF-ELSE-CONDITION to check if the AMOUNT is smaller, equal, or even bigger than 5.
-
if (…) {…} else {…}
-
Accordingly disable or enable the button.
-
At same time after every click onto your button you should save the current amount of clicks back to your database.
This would make sure, that the clicked button-amount never would get lost, since it is saved inside your database for each of users.
Now your turn —> generate all the functions and solve your issue.
EDIT: ADDITIONAL-TIP:
If you want to know if the code has any errors or TYPOS, just paste the code into your Wix-Editor into the code-section and all the ERRORS will be marked → RED!

As we can see —> conter <— was a real TYPO !!!
Instead of → conter ← of course it should be —> counter <—
Now you should have enough informations, to be able to solve your issue by your own.