nf_get_ip

Get User IP.

Description

(string) nf_get_ip(); 

Returns the IP address of the current visitor

Returns (string)

$ip User's IP address


Usage

  1. if ( !function_exists( 'nf_get_ip' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = nf_get_ip(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/deprecated/includes/functions.php  
  1. function nf_get_ip() { 
  2.  
  3. $ip = '127.0.0.1'; 
  4.  
  5. if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { 
  6. //check ip from share internet 
  7. $ip = $_SERVER['HTTP_CLIENT_IP']; 
  8. } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { 
  9. //to check ip is pass from proxy 
  10. $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; 
  11. } elseif( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { 
  12. $ip = $_SERVER['REMOTE_ADDR']; 
  13. return apply_filters( 'nf_get_ip', $ip );