1

How would you go about creating a daily quota for posts? I have a simple photo gallery where users can submit images, problem is some people are a bit too excited. I'd like to limit submission to let's say 10 per day per user. Any tips how to approach this welcomed.

1

You would have to hide the button or page where users could upload a photo.

To do this you could query for all that users entries with today's postDate. If the total is equal to or more than 10 then you'd redirect them to a different page or hide/disable the button that submits an entry.

Something along the lines of the following

add-image.twig

{% set todaysEntryCount = craft.entries.section( 'images' ) authorId( currentUser.id ).postDate( '> ' ~ now|date_modify('-1 day') ).total() %}
{% if daysEntryCount >= 10 %}
  {% redirect /your-images?message=dailylimit %}
{% endif %}

or

{% if daysEntryCount < 10 %}
   <button type="submit">Add your image</button>
{% endif %}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.