WordPress.org

Ready to get started?Download WordPress

Forums

How to allow commenting on Drafts... (1 post)

  1. Aubrey Portwood
    Member
    Posted 1 year ago #

    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
    }

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 1 year ago by Aubrey Portwood
  • This topic is not resolved
  • WordPress version: 3.3.2