Resource management with Pro?

Home Forums Calendar Products Events Calendar PRO Resource management with Pro?

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #247229
    unhinged
    Participant

    I 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.

    #252809
    unhinged
    Participant

    Can I get some kind of response on this? “No, this is impossible”, “Check out this hook”, “This is in our roadmap” … Anything.

    #255795
    unhinged
    Participant

    Anyone?

    #262466
    Barry
    Member

    Hi 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?

    #271266
    unhinged
    Participant

    Perfect. 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.

    #271405
    unhinged
    Participant

    Searching the source, it looks like the hook is actually tribe_events_event_save. When I hooked into save_posts_tribe_events nothing happened but the former was called as expected.

    #275045
    Barry
    Member

    Searching the source, it looks like the hook is actually tribe_events_event_save. When I hooked into save_posts_tribe_events nothing 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!

     

    #275056
    Barry
    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.)

    #701601
    Barry
    Member

    Hi! 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!

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Resource management with Pro?’ is closed to new replies.