Saltar navegación

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

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

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 hace 4 años, 11 meses. 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)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por davidR-12 hace 4 años, 10 meses.

Asistido por: Christian Cox.

Autor
Mensajes
#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