preprocess_comment

最后更新于:2021-11-27 18:20:27

apply_filters( ‘preprocess_comment’, array $commentdata )

Filters a comment’s data before it is sanitized and inserted into the database.

参数

$commentdata

(array)
Comment data.

源文件

文件: gc-includes/comment.php

View on Trac

add_filter( 'preprocess_comment' , 'preprocess_comment_remove_url' );

<?php
function preprocess_comment_remove_url( $commentdata ) {
   // Always remove the URL from the comment author's comment
   unset( $commentdata['comment_author_url'] );

   // If the user is speaking in all caps, lowercase the comment
   if( $commentdata['comment_content'] == strtoupper( $commentdata['comment_content'] ) ) {
      $commentdata['comment_content'] = ucwords( strtolower( $commentdata['comment_content'] ) );
   }

   return $commentdata;
}
?>