$data = $submission->get_posted_data(); if (!empty($data)) { // create post $postarr = array( "post_title" => "New Event" "post_status" => "new", "post_type" => "events", "post_status" => "publish" ); $post_id = wp_insert_post($postarr, $wp_error = false);