Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 112926

Cerzky on "Insert New Post during plugin registration->Headers Already Sent Error"

$
0
0

This is my error.

The plugin generated 197 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

I've narrowed it down to the wp_insert_post line as where the error is generated from. Any suggestions?

function employee_plugin_activate(){
$newpage= 'Employee Archive';
if ((isset($_POST['Employee Archive']) == false) && (get_page_by_title('Employee Archive') == false )){
$my_page = array(
	'post_title' => 'Employee Archive',
	'post_content' => 'IT WORKS',
	'post_status' => 'publish',
	'post_type' => 'page',
	'post_author' => 1,
	'post_category' => array()
);
	$post_id = wp_insert_post($my_page);
	//wp_insert_post($my_page);
}//end if
}//end function
register_activation_hook( __FILE__, "employee_plugin_activate");

Perhaps someone can debug this for me, I've checked all white space issues and that is not the problem. The error happens when wp_insert_post is called. The plugin works, it just generates this annoying error.

$post_id = wp_insert_post($my_page); // causing error

Thanks.

http://wordpress.org/extend/plugins/wp-insert-post/


Viewing all articles
Browse latest Browse all 112926

Trending Articles