How to see the IP address of users in WordPress

A few days ago I was wondering how to show the IP address of users in WordPress separately In this post I will show you how to show the IP address of the visitors to WordPress. You can create your own IP address detection site using these codes. So whenever a visitor visits your blog or website, he can see his own IP address.



You have to do two things for this. The first is to open the function.php file of your theme and copy the following code into the file and paste it.



// check ip from share internet

$ ip = $ _SERVER ['HTTP_CLIENT_IP'];

} elseif (! empty ($ _SERVER ['HTTP_X_FORWARDED_FOR'])) {

// to check

$ 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 job is over. Now it's time to start the second job. The second task is very simple. If you want to show the IP address of users in your post, page or specific WordPress widget, enter the following shortcut.

[show_ip]

We hope you read this post and understand how you will show an IP address in the WordPress widget
Previous Post Next Post

Contact Form