pre_comment_user_agent

Filters the comment author's browser user agent before it is set.

Description

apply_filters( 'pre_comment_user_agent', (string) $commentdata_comment_agent ); 

Parameters (1)

0. $commentdata_comment_agent (string) => ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' )
The isset commentdata comment agent commentdata comment agent.

Usage

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

Defined (1)

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

/wp-includes/comment.php  
  1. $commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) );