The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Insert New Post during plugin registration->Headers Already Sent Error (1 post)

  1. Cerzky
    Posted 3 years ago #

    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);
    }//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



Topic Closed

This topic has been closed to new replies.

About this Topic