Support » Plugin: Events Manager » Events Manager not totally compatible with WP All Import

  • If you import items with WP All Import as the Event post type created by Events Manager, they aren’t given an Event ID.

    The action below should cause Event IDs to be created by Events Manager when events are imported with WP All Import; however they will be saved with the status ‘publish’, regardless of your WP All Import settings.

    // Create a proper EM_Event object in the database when an event-type post is
    // imported with WP All import
    add_action('pmxi_saved_post', 'post_saved', 10, 1);
    function post_saved($post_id) {
      if (class_exists(EM_Event)) {
        $event_post = get_post($post_id);
    
        // Only create a new event entry if the imported post is of type event and
        // there is not an existing event for this post
        $existing_event = em_get_event($event_post->ID, 'post_id');
        if ($event_post->post_type == 'event' && empty($existing_event->event_id)) {
          $event = new EM_Event();
          $event->load_postdata($event_post);
          $event->save();
        }
      }
    }

    I’ve also added this as a gist on GitHub in case anybody can improve it.

    https://gist.github.com/jsit/98524a8ba4a97b9fd8db

    Cross-posted here:
    https://wordpress.org/support/topic/wp-all-import-not-totally-compatible-with-events-manager

    https://wordpress.org/plugins/events-manager/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support caimin_nwl

    (@caimin_nwl)

    Thanks for this, I’ll pass it on to the Dev team.

    This doesn’t work on cron imports, for some reason; I’m looking into it.

    This doesn’t work on WP All Import’s cron imports, if “Allow anonymous event submissions?” is set to “No” in Events Manager settings, due to the permissions check on line 632 of classes/em-event.php. Not sure how to circumvent this yet.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Events Manager not totally compatible with WP All Import’ is closed to new replies.