Inserting new event from plugin
-
Hi so I’m trying to create a plugin than creates new events based on the data I provide so to test I wrote a very simple plugin:
/* Plugin Name: Pruebas */ add_action('admin_notices', 'pruebas'); function pruebas(){ global $pagenow; if ( $pagenow == 'plugins.php' ){ $new_event = new EM_Event; $new_event->event_name = "Inserted event test"; $new_event->event_start_date = '20/01/13'; $new_event->event_start_time = '20:00'; $new_event->event_end_date_date = '20/01/13'; $new_event->event_end_time = '23:00'; $new_event->post_content = 'This is the content of an inserted post'; $new_event->post_status = 'draft'; $new_event->location = new EM_Location(); $new_event->location->location_name = 'New test place'; $new_event->location->location_address = 'Lerdo 201'; $new_event->location->location_town = 'Toluca'; $new_event->location->location_country = 'mexico'; echo '<div class="updated"><pre>'.$new_event->save() ? print_r($new_event) : printf('Fail Save') .'</pre></div>'; } }
The created event shows on the front end but not the admin, and the post_status is wrong it is supposed to be draft but it saved as publish, and location also don’t work as expected. Any ideas?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Inserting new event from plugin’ is closed to new replies.