preprocess_comment

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

Description

add_filter( 'preprocess_comment', (callback) $array, (int) $int ); 

Parameters (2)

0. $array (callback) => array( $this, 'allow_logged_in_user_to_comment_as_guest' )
The array.
1. $int (int)
The int.

Usage

To run the hook, copy the example below.
  1. $array = apply_filters( 'preprocess_comment', $array, $int ); 
  2.  
  3. if ( !empty( $array ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the preprocess_comment callback 
  2. function filter_preprocess_comment( $array, $int ) { 
  3. // make filter magic happen here... 
  4. return $array
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'preprocess_comment', 'filter_preprocess_comment', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'preprocess_comment', 'filter_preprocess_comment', 10, 2 ); 

Defined (1)

The filter is defined in the following location(s).

/modules/comments/base.php  
  1. add_filter( 'preprocess_comment', array( $this, 'allow_logged_in_user_to_comment_as_guest' ), 0 );