comment_text hook

//***************************************
//***************************************
//********** COMMENT TEXT HOOK **********
//***************************************
//***************************************
add_filter( 'comment_text', 'custom_comment_text', 20, 3 );
function custom_comment_text( $comment_text, $comment, $args )
{
  
  //$comment array:
  //  "comment_ID":"3",
  //  "comment_post_ID":"333",
  //  "comment_author":"",
  //  "comment_author_email":"",
  //  "comment_author_url":"",
  //  "comment_author_IP":"162.158.159.37",
  //  "comment_date":"2020-08-31 15:29:38",
  //  "comment_date_gmt":"2020-08-31 15:29:38",
  //  "comment_content":"Test",
  //  "comment_karma":"0",
  //  "comment_approved":"1",
  //  "comment_agent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/527.36 (KHTML, like Gecko) Chrome\/84.0.4047.135 Safari\/527.36",
  //  "comment_type":"comment",
  //  "comment_parent":"0",
  //  "user_id":"0"

  
  if( $comment->comment_type === 'comment' )
  {
    $comment_text = '<p>Some text I added</p>' . $comment_text;
  }
  return $comment_text;
}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *