Skip Navigation

[Resolved] Limit amount of posts a user can submit

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

Problem:
How can I ensure any user will be able to submit a certain form only once?

Solution:
https://toolset.com/forums/topic/conditional-display-based-on-users-parent-post/#post-1194632

Note, the solution is valid for all type of Forms or content, you just need to change the View's Queried Post type, to make sure catching the item you do want users to submit with the form.

Relevant Documentation:
https://toolset.com/documentation/user-guides/access-control-texts-inside-page-content/
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
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 5 years, 10 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by toolset-dave 5 years, 10 months ago.

Assisted by: Beda.

Author
Posts
#1194489

Hello,

I have a Parent CPT and Child one and I need to set up conditional which checks if current logged in user has created any Parent post. Based on this will show/hide button on his profile page with link to Toolset form for creating Child post.

#1194632

We solve a similar issue (make sure a user can submit only n amounts of posts) 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

As you see it suggests a View where you display posts by author (currently logged in user) and output nothing (leave loop empty) if the user has authored any post (which in your case is the parent post type).
It instead outputs the "no items found" part which in this example is amplified with the form itself but that could be a link or anything else, leading to the form.

It will show only if the current user (which also refers to Guest) has no authored posts.
To hide the form from guests you would simply wrap the entire View shortcode in an Acces ShortCode or any HTML condition checking upon login status.
https://toolset.com/documentation/user-guides/access-control-texts-inside-page-content/
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

#1194779

Thank you Beda, it solved my issue.