How to Display a User’s IP Address in WordPress
Today i am going to share with you a sweet WordPress tutorial that will enable your WordPress blog to display visitor's IP(Internet Protocol) address using a ShortCode.
Next thing you need to do is add the following shortcode in your post, page, or in a sidebar widget.
Now your visitors will see the IP address from where they are visiting on your WordPress Blog.
Add IP detection to your Wordpress Blog:
Only Thing you need to do is copy and paste below code snippet in your functions.php file
// Display User IP in WordPress Blog
function get_the_user_ip() {
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
//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_his_ip', 'get_the_user_ip');
[show_his_ip] 
Nice blog helpful for those who are looking for some other coding to display the ip address of visitors to their blog ....I am here to share my experience ...I created a business website for my use in which the visitor can see their ip address once they visit my website ....I copied HTML coding from providers like Ip-Details.com they are providing html coding which will display the ip address of the visitors to their website to the visitor ...I just embed that code with my coding during website creation now my visitors can easily find their ip address and location once they visit my site ......
ReplyDeleteGood to see that you find the blog useful
ReplyDelete