Skip Navigation

[Resolved] How to disable a form from being filled multiple times

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

Problem:
The user would like to limit site users to create only one post in a custom post type. He built a view and added the form only when no posts are returned.

Solution:
It turned out that the user has actually a post created, that's why the form does not display.

This support ticket is created 4 years, 6 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
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 5 replies, has 2 voices.

Last updated by Tomer Helzer 4 years, 6 months ago.

Assisted by: Jamal.

Author
Posts
#1915741

I've tried to duplicate a similar solution to the one discussed around this topic, but each time it involved custom code that solved the problem to the specific user. I've tried using the "view" trick as explained at the end of the article, here:
https://toolset.com/documentation/legacy-features/views-plugin/how-to-create-custom-searches-and-relationships-for-users/

But there was either missing document or the new Toolset version doesn't support the required options.

Next, I tried customizing the code I founded in these threads to my website:
https://toolset.com/forums/topic/cred-before-save-data-allow-only-one-submition-of-the-form/#post-922696

But I don't know any code, so I was mostly guessing where I needed to change things. The cred_form_validate hook was mentioned several times, so I imagine the solution requires this.

#1915877

Hello and thank you for contacting the Toolset support.

Instead of using custom code, you can use a view that will check if the user has already created the number of allowed posts. Then you can put the form, using a shortcode, inside the view if no posts are found. Does it make sense?

If you are using the legacy editor for building view, you can put the form inside the wpv-no-items-found shortcode. Check this screenshot hidden link

If you are using the blocks editor for building the view, you can put the form in the loop template of the view's loop. Check this screenshot hidden link

I hope this helps. Let me know if you have any questions.

#1916741

Hi Jamal,

Your solution sounds really good, but for some reason it's not working for me. Here's what I did:
I created a view that selects the post type users create with the form.
I left it completely blank and entered the shortcode: [cred_form form="2580"] using the form's ID. I have also tried inserting the name of the form before using the ID.
I created a completely new user so that it will be the first time he creates the form, but nothing appeared where the view was located. Simply blank.

Did I miss something?

Thanks for the help,
Tom

#1917175

Hello Tom, and thank you for your feedback.

Would you like to allow me temporary access to check this view closely? Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#1917351

The view returns one Designer. hidden link
The form will display only when the view does not return anything

I changed the status of the post to Draft, so it won't be returned by the view and the form appeared. hidden link

I assume that you want the view to query only the posts that were created by the user, right?
I that case, you need to add a query filter on the author field. hidden link

#1917443

My issue is resolved now. Thank you!