Closed tw2113 closed 1 month ago
In the vein of https://github.com/WebDevStudios/wp-search-with-algolia/pull/407/files lets allow for customizing defaultHeaders.
Add to our code area:
if ( is_array( $custom_config['DefaultHeaders'] ) && ! empty( $custom_config['DefaultHeaders'] ) ) { $config->setDefaultHeaders( $custom_config['DefaultHeaders'] ); }
Example usage:
function wds_algolia_custom_searchclient_config( $config ) { $ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR']; $headers = [ 'X-Forwarded-For' => $ip_address, ]; $config['DefaultHeaders'] = $headers; return $config; } add_filter( 'algolia_custom_search_config', 'wds_algolia_custom_searchclient_config' );
See: https://wordpress.org/support/topic/how-to-set-extra-header/
This has been merged into the release290 branch.
In the vein of https://github.com/WebDevStudios/wp-search-with-algolia/pull/407/files lets allow for customizing defaultHeaders.
Add to our code area:
Example usage:
See: https://wordpress.org/support/topic/how-to-set-extra-header/