Home › Forums › Front-end Issues › Check for duplicate post based on custom date field › Reply To: Check for duplicate post based on custom date field
I would suggest a different direction https://www.advancedcustomfields.com/resources/acf-validate_value/
Basically, you would create a filter for both the coach and the time field.
Both of the field values will be in the $_POST[‘acf’] array during the validation. You can get both the coach and the date/time. The you do a query of the existing posts to see if there is one that already exists with that combination. If there is then the validate fails.
There is an example here of validating a single field to make sure it is unique https://support.advancedcustomfields.com/forums/topic/accept-only-unique-values/#post-45359 and it should not be that much of a leap to use 2 fields in the query rather than a single field.
This would eliminate the need to redirect back to the page and make someone start over again.
Although, I’d probably also try to include some type of list that shows when each coach is actually available since it would be quite frustrating if you have to try a dozen times. Basically the validation would be to enforce the availability information already supplied.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.