I am attempting to write a wordpress plugin which edits this content of the released publish. I have attempted by using this:

function edit( $post_ID ) {
    $content = "Hello. This is a test.";

    $post_info = get_post($post_ID);    
    $post_info->post_content = "$content";

    wp_update_post( $post_info );
}

add_action('publish_post', 'edit');

Although that isn't working. It makes its way into a loop (since it is being released again) and just finishes if this occasions out. Would there be a different way to do that? Just help. :)

I believe you need a static variable within the function that tracks if the function continues to be known as. Also, wordpress_update_publish takes an assortment instead of an item -- a minimum of that's generate an income get it done.

function edit( $post_ID ) {
    static $plugin_has_updated = false;
    if ($plugin_has_updated) return;
    $plugin_has_updated = true;
    $content = "Hello. This is a test.";
    $post_arr = array("ID"=>$post_ID, "post_content"=>$content);
    wp_update_post( $post_arr );
}

add_action('publish_post', 'edit');