WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Commenting on draft posts (2 posts)

  1. Joost
    Member
    Posted 4 years ago #

    Hi all,

    I changed my theme so that for logged in users (editor and above) all articles are shown on the front-end of the site. That means the future and pending posts too.

    When I place a comment below a future post all goes well, but when I try to place a comment below a pending post, all I get is a blank page.

    Anyone any clue?

  2. Joost
    Member
    Posted 4 years ago #

    Found the solution.

    In wp-comments-post.php there is the following snippet:

    if ( empty($status->comment_status) ) {
    	do_action('comment_id_not_found', $comment_post_ID);
    	exit;
    } elseif ( !comments_open($comment_post_ID) ) {
    	do_action('comment_closed', $comment_post_ID);
    	wp_die( __('Sorry, comments are closed for this item.') );
    } elseif ( in_array($status->post_status, array('draft', 'pending') ) ) {
    	do_action('comment_on_draft', $comment_post_ID);
    	exit;
    } else {
    	do_action('pre_comment_on_post', $comment_post_ID);
    }

    Just replace
    do_action('comment_on_draft', $comment_post_ID);
    with
    do_action('pre_comment_on_post', $comment_post_ID);

    and remove the exit, and comments will be admitted.

Topic Closed

This topic has been closed to new replies.

About this Topic