How to see the IP Address of users in WordPress

In this post, I will show you how to show visitors IP address in WordPress. You can create your own IP address detection site using these codes. So whenever a visitor visits your blog or website, he will be able to see his own IP address.

For this, you need to do two things. The first is to open the function.php file of your theme and copy and paste the following codes into the file.


/check ip from share internet
$ip = $_SERVER[‘HTTP_CLIENT_IP’];
} elseif ( ! empty( $_SERVER[‘HTTP_X_FORWARDED_FOR’] ) ) {
//to check ip is pass from proxy
$ip = $_SERVER[‘HTTP_X_FORWARDED_FOR’];
} else {
$ip = $_SERVER[‘REMOTE_ADDR’];
}
return apply_filters( ‘wpb_get_ip’, $ip );
}


add_shortcode(‘show_ip’, ‘get_the_user_ip’);

The first task was over. Now it’s time to start the second task. The second task is much easier. If you want to show the IP address of users in your post, page, or any specific WordPress widget, enter the following shortcode.

[show_ip]

We hope that after reading this post you will understand how to show IP address in WordPress widget

If you have any questions you can let us know by commenting below.