Filter hook 'log_query_custom_data'

in WP Core File wp-includes/class-wpdb.php at line 2393

View Source

log_query_custom_data

Filter Hook
Description
Filters the custom data to log alongside a query. Caution should be used when modifying any of this data, it is recommended that any additional information you need to store about a query be added as a new associative array element.

Hook Information

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

Hook Parameters

Type Name Description
array $query_data Custom query data.
string $query The query's SQL.
float $query_time Total time spent on the query, in seconds.
string $query_callstack Comma-separated list of the calling functions.
float $query_start Unix timestamp of the time at the start of the query.

Usage Examples

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

function my_custom_filter($query_data, $query, $query_time, $query_callstack, $query_start) {
    // Your custom filtering logic here
    return $query_data;
}

Source Code Context

wp-includes/class-wpdb.php:2393 - How this hook is used in WordPress core
<?php
2388  		 * @param string $query           The query's SQL.
2389  		 * @param float  $query_time      Total time spent on the query, in seconds.
2390  		 * @param string $query_callstack Comma-separated list of the calling functions.
2391  		 * @param float  $query_start     Unix timestamp of the time at the start of the query.
2392  		 */
2393  		$query_data = apply_filters( 'log_query_custom_data', $query_data, $query, $query_time, $query_callstack, $query_start );
2394  
2395  		$this->queries[] = array(
2396  			$query,
2397  			$query_time,
2398  			$query_callstack,

PHP Documentation

<?php
/**
		 * Filters the custom data to log alongside a query.
		 *
		 * Caution should be used when modifying any of this data, it is recommended that any additional
		 * information you need to store about a query be added as a new associative array element.
		 *
		 * @since 5.3.0
		 *
		 * @param array  $query_data      Custom query data.
		 * @param string $query           The query's SQL.
		 * @param float  $query_time      Total time spent on the query, in seconds.
		 * @param string $query_callstack Comma-separated list of the calling functions.
		 * @param float  $query_start     Unix timestamp of the time at the start of the query.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 5
  • File: wp-includes/class-wpdb.php
Related Hooks

Related hooks will be displayed here in future updates.