apply_filters( 'relevanssi_remote_addr', string $remote_address )

This filter hook filters the user IP address before Relevanssi logs it.


(string) The user IP address from $_SERVER['REMOTE_ADDR'].

More information

Suppose you have chosen to log the user IP address in the Relevanssi logs (warning: it may be illegal). In that case, Relevanssi passes the IP address from $_SERVER['REMOTE_ADDR'] through this filter hook before Relevanssi stores it in the log.

A good use for this filter hook is to anonymize the IP addresses. This filter hook is also necessary in cases where $_SERVER['REMOTE_ADDR'] doesn’t contain the actual user IP (in some cases $_SERVER['HTTP_FORWARDED_FOR'] has the correct IP).

Here’s a simple anonymizer (based on geertw/php-ip-anonymizer) you can use in your theme functions.php:

add_filter( 'relevanssi_remote_addr', 'rlv_anonymize_ip' );
function rlv_anonymize_ip( $ip ) {
  return inet_ntop( inet_pton( $ip ) & inet_pton( '' ) );

This function will anonymize to Note that this is not legal advice, and I give no guarantee that this method is good enough for GDPR purposes.