Skip Navigation

[Resuelto] Limiting number of posts per user to a custom post type

This support ticket is created hace 5 años, 8 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Este tema contiene 2 respuestas, tiene 3 mensajes.

Última actualización por miguelM-3 hace 5 años, 8 meses.

Autor
Mensajes
#1221104

Hi there,

I have a custom post type, and would like to limit to "one" the number of time a user can post to the post type.

This is because the post type makes a user profile on the site (submitted from the front end using Toolset Forms), and we want that user profile to be limited to one per user.

I hope you can help.

Many thanks for your time,
Andrew.

#1221387

It's not possible natively but there is a trick (3, actually) how to achieve that.

1. Create a Toolset Form to create such posts, and put that Toolset Form to a View's loop "no items found"
2. Set the View to display posts by the current logged in user and limit it to 1
3. Put the View on a page

If the view has no results (the user did not submit any such posts) then the "No items found" section is triggered and hence, the form is shown with which the user can submit new posts

1. Or, use custom code
2. Such custom code is shown as an example here:
enlace oculto
==> It also uses Toolset Forms

1. If you do not plan to use Forms, you can count posts by user and use a Custom ShortCode to apply a condition to stop submitting new
2. Such custom code is shown as an example here:
enlace oculto
3. That code can be used as a ShortCode in an HTML condition of Toolset or, if modified, even apply on the save_post hook of WordPress. More information about these 2 details here:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post

#1237714

Hi. I do not see the links you give to Andrew in the answer and he also interjects me. Is there any way to see it?