Hey, long time no chat eh 🙂
As I’ve mentioned previously, I am using the gist you created for a front-end editor. It utilizes eo_insert_event(). I was wondering, does this return some sort of error message if the event is not created successsfully? I would like to be able to provide some feedback to the user on whether or not their event was created successfully. If not, would I just need to validate the form prior to submitting the data to ensure the event is created successfully?
-
This topic was modified 10 years, 10 months ago by
Gabriel David.

Gabriel David
Yes it does, in fact it behaves almost identically to wp_insert_post()
. In case of an error a WP_Error
object is returned. In the case of an event submission form, it should be sufficient to try eo_insert_event()
which performs its own validation.
Of course, eo_insert_event()
requires a DateTime object for ‘start’, ‘end’ and (optionally) ‘repeat until’ dates, so you’ll probably need to perform some sort of validation when converting the value entered by the user into a DateTime object. For this you can use eo_check_datetime()
(- which is not well documented but is simply a wrapper for date_create_from_format()
with a php5.2 fallback. You can find it in includes/event-organiser-utility-functions.php
). This function allows you to pass a string date value, and the format (you expect) it is in, and it’ll try to parse that value into a DateTime object. If it can’t, it returns false
.

Stephen Harris