cgottfried108
Forum Replies Created
-
Forum: Plugins
In reply to: [EZ Emails] Saving sent emails?I would be interested in this too!
It seems that the function duplicate() after the switch_to_blog creates wp_posts record in blog 1 and em_events record in blog 5. So I got around this by copying the new record in wp_5_em_events into wp_em_events. Then I was able to change the status of post to publish. Not very elegant, but it works.
If you have a better solution that doesn’t do custom database queries, that would be awesome, Angelo.
Thanks, Angelo. I’m not sure how to hook into the em_event_save filter from a function called by the bulk actions…
However, I did get the event to duplicate as published on the same subsite using the following code. I’m now trying to figure out how to modify it to save to a different subsite. When I included the commented lines regarding the blog identifier (marked with 3 asterisks to make it easier to identify here), wp_posts saved in the intended, switched subsite, while em_events saved to the first subsite:
// Push event from event form subsite to live site function push_event($post_id) { global $wpdb, $current_user, $blog_id; global $switched; global $EM_Event; // First get info from record in form subsite $EM_Event = em_get_event($post_id, 'post_id'); // Switch to main site and insert event //switch_to_blog(1); //*** // Duplicate event $new_event = $EM_Event->duplicate(); // Generate new slug $slug = $new_event->event_name; $updated_slug = wp_unique_post_slug( $slug, $new_id, 'publish', 'event', 0 ); // Update em_events table $new_event->event_status = 1; $new_event->event_name = $slug; $new_event->event_slug = $updated_slug; //$new_event->blog_id = 1; //*** $new_event->save(); // Update posts tabler $new_id = $new_event->post_id; $wp_post = array( 'ID' => $new_id, 'post_name' => $updated_slug, 'post_date' => date('Y-m-d H:i:s', strtotime('today')), 'post_date_gmt' => gmdate('Y-m-d H:i:s', strtotime('today')), 'post_status' => 'publish' ); wp_update_post( $wp_post ); wp_publish_post( $wp_post ); }