I am using a cron job to run a php script to add events. My script resulted in events with Pending status.
I have stripped back the script to add a single, hard coded event. This stil results in a Pending status. The event user is also ‘anon_submitter’ instead of the admin (I set author to ID 1).
I am open to suggestions on how to sort this so that the events are Published. (Yes, I do not want to review them as they are added by my code and not an anonymous visitor).
$location_id = 75; $author_id = 1; # admin user. $event_start_date = '2017-01-31'; $minute = date('i'); // Change the minute. $event_time = '20:'.$minute.':15'; $event_end_date = $event_start_date; $event_start_time = $event_time; $event_end_time = $event_start_time; $EM_Event = new EM_Event(); $EM_Event->event_name = 'EM Test'; //$EM_Event->event_slug = $slug; $EM_Event->post_content = '<p>This is the description of EM Test event.</p>'; $EM_Event->event_owner = $author_id; $EM_Event->location_id = $location_id; $EM_Event->event_start_date = $event_start_date; $EM_Event->event_end_date = $event_end_date; $EM_Event->event_start_time = $event_start_time; $EM_Event->event_end_time = $event_end_time; $EM_Event->start = strtotime($EM_Event->event_start_date.' '.$EM_Event->event_start_time); $EM_Event->end = strtotime($EM_Event->event_end_date.' '.$EM_Event->event_end_time); // Disable saving during development. $EM_Event->save(); echo '<p>Event post ID: ', $EM_Event->post_id, '</p>'; echo '<p>Event event ID: ', $EM_Event->event_id, '</p>';
- You must be logged in to reply to this topic.