Home › Forums › Calendar Products › Events Calendar PRO › Resource management with Pro?
- This topic has 8 replies, 2 voices, and was last updated 11 years, 8 months ago by
Barry.
-
AuthorPosts
-
June 24, 2014 at 8:07 am #247229
unhinged
ParticipantI already have a site with the Pro calendar. Now we are changing requirements a bit (yay!) and the calendar need to have more of a robust booking process akin to resource management. Basically, we need the plugin to prevent two events from occurring at the same venue on the same time.
Is there a way to do this out of the box? If not, is there ‘pre-save’ hook that I can tap into to run some extra validation and cancel the save if necessary? Pretty please say yes.
June 26, 2014 at 7:42 am #252809unhinged
ParticipantCan I get some kind of response on this? “No, this is impossible”, “Check out this hook”, “This is in our roadmap” … Anything.
June 27, 2014 at 12:36 pm #255795unhinged
ParticipantAnyone?
June 30, 2014 at 11:21 am #262466Barry
MemberHi unhinged,
I’m sorry first of all for the delay in getting you a response.
We had a bit of a procedural failing here and the thread was assigned to a team member who wasn’t actually in a position to reply – please accept our apologies on that count.
Basically, we need the plugin to prevent two events from occurring at the same venue on the same time.
Is there a way to do this out of the box? If not, is there ‘pre-save’ hook that I can tap into to run some extra validation and cancel the save if necessary? Pretty please say yes.
There’s no built-in mechanism for this as such, but it should definitely be possible to implement it as a customization. As with most tasks like this there are a few ways you might approach it, but here’s an outline of the kind of strategy I’d probably look at in the first instance:
- Listen out for save events by hooking into save_posts_tribe_events – you may wish to use a fairly high priority for this
- Within your callback, launch a query (whether by working directly with WP_Query or via tribe_get_events() – which is essentially an event-specific wrapper for the same thing) to determine if there are any other events taking place in the same window of time
- Iterate across the result set and inspect the venue for each
- If you find there is an event with the same venue that “collides” with the newly created one – kill the new one/display an error message/whatever you need to do in your case
So while it’s definitely a custom development task, I hope that gives you a sort of basic outline as to how you might tackle this. Does that help at all?
July 3, 2014 at 8:30 am #271266unhinged
ParticipantPerfect. This is exactly what I was hoping for (aside from learning that the functionality was already built in). No worries about the disconnect. It sounds pretty reasonable.
July 3, 2014 at 9:32 am #271405unhinged
ParticipantSearching the source, it looks like the hook is actually
tribe_events_event_save. When I hooked intosave_posts_tribe_eventsnothing happened but the former was called as expected.July 4, 2014 at 12:08 am #275045Barry
MemberSearching the source, it looks like the hook is actually
tribe_events_event_save. When I hooked intosave_posts_tribe_eventsnothing happened but the former was called as expected.Apologies, my fault – it should be save_post (singular not plural). The basic form is:
save_post_{post_type}
So in the case of events:
save_post_tribe_events
Apologies for the confusion!
July 4, 2014 at 12:08 am #275056Barry
Member(…naturally, if you’re happy with the other hook and find that works for you then you could stick to that – there is often a myriad ways of tackling things like this.)
August 26, 2014 at 8:37 am #701601Barry
MemberHi! It’s been a while so I’m going to go ahead and close this thread. If we can help with anything else, though, please don’t hesitate to create new threads as needed. Thanks!
-
AuthorPosts
- The topic ‘Resource management with Pro?’ is closed to new replies.
