caldera_forms_get_ip

Get User IP.

Description

(string) caldera_forms_get_ip(); 

Returns the IP address of the current visitor

Returns (string)

$ip User's IP address


Usage

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

Defined (1)

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

/processors/functions.php  
  1. function caldera_forms_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.  
  14. return $ip; 
  15.