Filter hook 'http_headers_useragent'

in WP Core File wp-includes/class-wp-http.php at line 211

View Source

http_headers_useragent

Filter Hook
Description
Filters the user agent value sent with an HTTP request.

Hook Information

File Location wp-includes/class-wp-http.php View on GitHub
Hook Type Filter
Line Number 211

Hook Parameters

Type Name Description
string $user_agent WordPress user agent string.
string $url The request URL.

Usage Examples

Basic Usage
<?php
// Hook into http_headers_useragent
add_filter('http_headers_useragent', 'my_custom_filter', 10, 2);

function my_custom_filter($user_agent, $url) {
    // Your custom filtering logic here
    return $user_agent;
}

Source Code Context

wp-includes/class-wp-http.php:211 - How this hook is used in WordPress core
<?php
 206  			 * @since 5.1.0 The `$url` parameter was added.
 207  			 *
 208  			 * @param string $user_agent WordPress user agent string.
 209  			 * @param string $url        The request URL.
 210  			 */
 211  			'user-agent'          => apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ), $url ),
 212  			/**
 213  			 * Filters whether to pass URLs through wp_http_validate_url() in an HTTP request.
 214  			 *
 215  			 * @since 3.6.0
 216  			 * @since 5.1.0 The `$url` parameter was added.

PHP Documentation

<?php
/**
			 * Filters the user agent value sent with an HTTP request.
			 *
			 * @since 2.7.0
			 * @since 5.1.0 The `$url` parameter was added.
			 *
			 * @param string $user_agent WordPress user agent string.
			 * @param string $url        The request URL.
			 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/class-wp-http.php
Related Hooks

Related hooks will be displayed here in future updates.