How can I allow editors to leave comments on posts that have not yet been published?

It depends on who the comments are for, are they for the administrators and editors or are they also for the contributors?

I’ve setup a system, somewhat elaborate, which handles some of what you’re asking, however the easiest way to achieve something like this is by using custom fields.

In particular, a custom metabox with repeating fields which allows you to add multiple fields (for example textareas) for which editors can leave their comments.

Depending on how you have your blog structured, contributors may or may not be able to see those comments. Usually they will see them if they have access to the dashboard. If on the other hand they are contributing via the front end of your site then they wont see those comments unless you query your custom fields into your template.

Either way, you can also restrict the view of those fields to a certain user class.

I highly recommend using the WP Alchemy Metabox Class found HERE

It’s powerful, well documented and relatively easy to use with plenty of example metabox files that you can use right out the gate and to help you wrap your head around their usage.

UPDATE

Ok I’m just thinking aloud here but my thoughts on this are that you will still need to use a custom field from within the post-edit screen for which your editor can leave his/her comment however on post publish, you then hook into wp_comments and take the value of the custom field and have it inserted into comments.

However it might be just as easy to call the custom field value from within your theme file but within the section where you display your actual comments. Then in fact you could quite easily style the comments to make them standout in a unique fashion (being editorial comments).

But if you desperately don’t want to do that then you need to be thinking along the lines of… (conceptual code below)

add_action('pending_to_publish_CUSTOM_POST_TYPE_NAME', 'insert_editor_comment');

function insert_editor_comment( $data){

$time = current_time('mysql');

$data = array(
    'comment_post_ID' => 1,
    'comment_author' => 'admin',
    'comment_author_email' => '[email protected]',
    'comment_author_url' => 'http://',
    'comment_content' => 'content here',
    'comment_type' => '',
    'comment_parent' => 0,
    'user_id' => 1,
    'comment_author_IP' => '127.0.0.1',
    'comment_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)',
    'comment_date' => $time,
    'comment_approved' => 1,
);

wp_insert_comment($data);
}

Again this is just conceptual, I’ve never done something like this but it should get you thinking along the right path. If I get a moment I might even test it out! Although I am sure many others could chime in and seal this deal for you quite easily.

Leave a Comment