Beispiel #1
0
 public function insert($data, $userId)
 {
     $post = new Post();
     $post->post_title = $data['comments'];
     $post->post_type = $this->slug;
     $post->post_status = 'publish';
     $post->post_author = $userId;
     $post->ping_status = 'closed';
     $temp = array('timeslot_user' => $userId, 'timeslot_venue' => str_replace('/', '', $data['id']), 'date' => $data['date'], 'time_from' => $data['time_from'], 'time_to' => $data['time_to'], 'time_to' => $data['time_to'], 'title' => $data['comments']);
     $post->save();
     foreach ($temp as $metaKey => $metaValue) {
         $postmeta = new PostMeta();
         $postmeta->timestamps = FALSE;
         $postmeta->post_id = $post->ID;
         $postmeta->meta_key = $metaKey;
         $postmeta->meta_value = $metaValue;
         $postmeta->save();
     }
     return $post;
 }
Beispiel #2
0
 public function insert($data, $userId)
 {
     $post = new Post();
     $post->post_title = $data['title_a'];
     $post->post_name = sanitize_title_with_dashes($data['title_a']);
     $post->post_type = $this->slug;
     $post->post_status = 'publish';
     $post->post_author = $userId;
     $post->ping_status = 'closed';
     $temp = array('address' => $data['address'], 'city' => $data['city'], 'state' => $data['state'], 'postcode' => $data['postcode'], 'country' => $data['country']);
     $post->save();
     foreach ($temp as $metaKey => $metaValue) {
         $postmeta = new PostMeta();
         $postmeta->timestamps = FALSE;
         $postmeta->post_id = $post->ID;
         $postmeta->meta_key = $metaKey;
         $postmeta->meta_value = $metaValue;
         $postmeta->save();
     }
     return $post;
 }