jjshaffer
Forum Replies Created
-
Forum: Plugins
In reply to: [The Events Calendar] Events Calendar time/date won’t updateAs a follow-up; this does work
$event_id = tribe_events()->set_args( $args )->create()->ID;
Forum: Plugins
In reply to: [The Events Calendar] Events Calendar time/date won’t updateI have a similar issue, though I have partially solved it. I have a function that either updates an event if it already exists or creates a new one if it doesn’t. Initially I was using tribe_create_event($args) to do both of these things by setting the ID field as necessary in $args.
However, it didn’t seem to work for either updating (by setting ID to the appropriate $post_id) or creating events (with ID=>0). I changed the update section to instead use tribe_update_event($post_id, $args) and it works now. This might solve the issue you’re describing.
I still can’t seem to use tribe_create_event($args) to create an event. It seems to create a post (and matching metadata) with the appropriate information and returns the post_id, but doesn’t create an entry on the {prefix}_tec_events table and isn’t visible on the calendar. I get a page not found error if I try to link directly to the post.Using Tribe__Events__API::createEvent( $args ) has the same result.
With debug mode enabled, I get this error:
Notice: Function wpdb::prepare was called?incorrectly. Unsupported value type (array). Please see?Debugging in WordPress?for more information. (This message was added in version 4.8.2.) in?/home/wp_nq8jjk/calontirorg.stage.site/wp-includes/functions.php?on line?5835
An example code snippet – this creates a post and post metadata but doesn’t create an event in tec_events table:
$args = array(‘ID’=>’0’, ‘post_title’ => ‘test event’, ‘post_status’ => ‘publish’, ‘start_date’ => ‘2023-02-25 09:00:00’, ‘end_date’ => ‘2023-02-25 12:00:00’,);
$event_id = tribe_create_event($args);
I’m on:
WP version 6.1.1
PHP version 7.4.25
The Events Calendar version 6.0.9
Understrap Child Theme version 0.2.2