MyBB Community Forums

Full Version: Limit the number of accesses to a custom page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a way to prevent users from accessing a custom page for more than X times each day?

Basically I would like to make users able to visit that page up to 10 times each day, and then display a no permissions error or another custom message which states that page has been already visited the maximum time allowed for that day.

I guess it's needed a counter in the database which resets itself at midnight or after 24 hours since each request, but I don't know how it can be linked to each user.. ideas?
(2015-07-16, 08:22 PM)ShadowOne Wrote: [ -> ]I guess it's needed a counter in the database which resets itself at midnight or after 24 hours since each request, but I don't know how it can be linked to each user.. ideas?

By the UID column of course. It's 0 for guests and unique for all users. Store that and bump the number of visits in DB based on $mybb->user['uid'] Also store the last visit dateline to reset the count if it's older than 1 day.