pre_comment_user_agent
Filter HookDescription
Filters the comment author's browser user agent before it is set.Hook Information
File Location |
wp-includes/comment.php
View on GitHub
|
Hook Type | Filter |
Line Number | 2165 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$comment_agent
|
The comment author's browser user agent. |
Usage Examples
Basic Usage
<?php
// Hook into pre_comment_user_agent
add_filter('pre_comment_user_agent', 'my_custom_filter', 10, 1);
function my_custom_filter($comment_agent) {
// Your custom filtering logic here
return $comment_agent;
}
Source Code Context
wp-includes/comment.php:2165
- How this hook is used in WordPress core
<?php
2160 *
2161 * @since 1.5.0
2162 *
2163 * @param string $comment_agent The comment author's browser user agent.
2164 */
2165 $commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) );
2166 /** This filter is documented in wp-includes/comment.php */
2167 $commentdata['comment_author'] = apply_filters( 'pre_comment_author_name', $commentdata['comment_author'] );
2168 /**
2169 * Filters the comment content before it is set.
2170 *
PHP Documentation
<?php
/**
* Filters the comment author's browser user agent before it is set.
*
* @since 1.5.0
*
* @param string $comment_agent The comment author's browser user agent.
*/
Quick Info
- Hook Type: Filter
- Parameters: 1
- File: wp-includes/comment.php
Related Hooks
Related hooks will be displayed here in future updates.