The following function works well for creating Drafts but when using $status='publish' I get an errror:
Warning: in_array() [function.in-array]: Wrong datatype for second argument in ...wp-includes\post.php on line 703
Fatal error: Call to undefined function: get_userdata() in ...\wp-includes\link-template.php on line 85
function wp_ai_post($title, $content, $timestamp = null, $category = null, $status = 'draft', $authorid = null, $allowpings = true, $allowcomments = true ) {
global $wpdb;
$date = ($timestamp) ? gmdate('Y-m-d H:i:s', $timestamp) : null;
$postid = wp_insert_post(array(
'post_title' => $title,
'post_content' => $content,
'post_content_filtered' => $content,
'post_category' => $category,
'post_status' => $status,
'post_author' => $authorid,
'post_date' => $date,
'comment_status' => $allowcomments,
'ping_status' => $allowpings
));
do_action('publish_post', $postid);
return $postid;
}
Any ideas ?