Web dev challenge

I’m trying to edit a customers WordPress website. it’s a AI image generation website and they want to be able to have people click a button, gain 8 credits, and then be able to generate images with those credits but not be able to do it twice. His idea was how newspaper sites allow you to view 1 or 2 articles then you get blocked out.

I think this would be done by checking the users IP address then log their IP address in a database if they get the free credits once. Then check if they have used them and redirect to pay wall if they try to click the button again.

any advice, articles, feedback, or code snippets would be appreciated, it was built with WordPress and WooCommerce and it has php.

While logging IP addresses can help prevent abuse, relying solely on IP addresses for user identification has limitations (e.g., multiple users behind the same IP, dynamic IPs). Consider combining this with user authentication for better accuracy.

I mean for a user to get credits he/she should be authenticated first, either by email or sth else unique.
I think in combination with IP address you can prevent them from getting credits twice for somehow

The client was saying they want to give credits without login, like how news article websites let you read one for free then block you. I was thinking I could simplify the login to only include email initially. or maybe store in their browser some kind of stored file or code to show they already got a free token.

The website has no email authentication for the users so if anyone wanted they could keep feeding fake emails to get free images anyways, that’s what happens when you pay someone on fiverr the cheap money lol. I’m just trying to increase engagement by streamlining login so people don’t leave before trying, they assume this will increase paid users or at least would like to test the theory.

But you are probably right, some form of login will probably be best.

If it’s Wordpress and Woocommerce why re-invent the wheel, just use on of the many available solutions, like these recommendations: 7 Best WordPress Paywall Plugins in 2024 (Compared)

If you want to polish your programming skills it’s better not to do this on a live client and his site.

That’s a good point too, i’ll look into it thanks!