Skip Navigation

[Resolved] How do I limit the amount of posts a user can create from a frontend form?

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to limit the number of posts a single User can create with a Form. The maximum number of posts allowed should be only one.

Solution: The easiest solution here is to use a View of these posts filtered by post author, where the author is the same as the current logged-in User. If any results are found, show nothing in the loop. If no results are found, show the Form by replacing the text in the "No items found" block with the corresponding Form shortcode or Form block.

Relevant Documentation:
See the first FAQ here - https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/#how-do-i-prevent-users-from-creating-more-than-one-contractor-post

This support ticket is created 4 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by davidR-12 4 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1567143

How do I limit the amount of posts a user can create from a frontend form? Currently they can create as many as they like and I want to limit it to one.

#1567383

The easiest way to do this is to use a View of this post type filtered by post author, set by the current logged-in User. If any results are found, you know the post author has already created one post, so show nothing. If no results are found, show the Form and allow the User to create their first post. More info about this approach in the first FAQ here: https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/#how-do-i-prevent-users-from-creating-more-than-one-contractor-post

#1569255

Thanks Christian, that works perfectly.

Regards,

David