Navigation überspringen

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

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

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 vor 4 Jahren, 10 Monaten. 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)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von davidR-12 vor 4 Jahren, 10 Monaten.

Assistiert von: Christian Cox.

Author
Artikel
#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