1. Home
  2. Developers
  3. wpinv_get_ip

wpinv_get_ip

Filters the IP address of the current visitor.

apply_filters( 'wpinv_get_ip', string $ip );

Parameters

Returns

$ip

(string) Current visitor’s IP address.

Examples

Set the current visitor’s IP address from United Kingdom IP address range. It will identify that the current visitor is from United Kingdom.

function _wpi_wpinv_get_ip( $ip ) {
    /*
     * Sample IP addresses for different countries.
     * 
     * 90.222.150.124    =>    Glasgow, Scotland, United Kingdom (GB)
     * 79.150.150.150    =>    Barcelona, Catalonia, Spain (ES)
     * 106.209.216.208   =>    Mumbai, Maharashtra, India (IN)
     * 220.240.220.240   =>    Sydney, New South Wales, Australia (AU)
     */
    $ip = '90.222.150.124';
    
    return $ip;
}
add_filter( 'wpinv_get_ip', '_wpi_wpinv_get_ip', 10, 1 );
Was this helpful to you? Yes No