Support

Account

Home Forums General Issues Validate a post doesn’t conflict with another post’s date/time field

Solving

Validate a post doesn’t conflict with another post’s date/time field

  • Ok bear with me on this one, I’ll try and simplify this as much as I can.
    Lets say I have a Custom Post Type of “Events”
    In those events I have a checkbox field for different kinds of events
    -Birthday
    -Anniversary
    -Housewarming etc

    In each post I have 2 date/time pickers one for start time and one for end time. If a start time is in the future the post status is set to “scheduled”.

    I’d like to do a check so no two types of events can be scheduled during the same time. So no two birthday events can have overlapping start and stop times.

    My first thought was to query any posts that are currently have a status of publish or future, then compare all that have the same type checkbox and then compare date/times but I’m not sure if I’m over complicating things…or not complicating things enough.

  • There is a solution here for accepting only unique values https://support.advancedcustomfields.com/forums/topic/accept-only-unique-values/#post-45359

    It is rather simple, but yes, you would need to validate both the start and end date and you would have to do one or more queries check the posts. Yes it would be complicated because you’re talking about (I think) basing uniqueness on 3 different fields.

  • Thanks so much I’ll take a look

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.