Support » Fixing WordPress » How to allow commenting on Drafts…

  • This is how I did it….

    add_action('comment_on_draft','pgm_commenting_on_draft');
    
    function pgm_commenting_on_draft(){
    	global $comment_post_ID;
    	global $current_user;
    
    	do_action('pre_comment_on_post', $comment_post_ID);
    
    		$data = array(
    		    'comment_post_ID' => $comment_post_ID,
    		    'comment_author' => $current_user->user_login,
    		    'comment_content' => $_POST['comment'],
    		    'comment_date' => current_time('mysql'),
    		    'comment_approved' => 1,
    		);
    
    		wp_insert_comment($data);
    	wp_redirect($_SERVER['HTTP_REFERER']); //to avoid exit
    }
  • The topic ‘How to allow commenting on Drafts…’ is closed to new replies.