Sunday, November 29, 2020
Home Blogging How to Display a User’s IP Address in WordPress

How to Display a User’s IP Address in WordPress

Just lately one in every of our customers requested us if it was potential to detect and show particular person guests’ IP deal with in WordPress. Our reply was in fact it’s. On this article, we’ll present you the best way to show consumer’s IP deal with in WordPress.

You need to use this to create your personal IP detection website. This manner when a web site customer views your website, they’ll see their very own IP deal with.

All you need to do is paste the next snippet in your theme’s features.php file or in a site-specific plugin.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Display User IP in WordPress
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_ip', 'get_the_user_ip');

Subsequent factor you want to do is add the next shortcode in your submit, web page, or in a sidebar widget.

[show_ip]

For those who’re utilizing the shortcode in your sidebar textual content widget, and it isn’t working, then you want to just remember to allow shortcode for sidebar widgets.

You May Also Like : How to Embed a Live Google+ Hangout Session in WordPress

We hope this text helped you show consumer’s IP deal with in your WordPress website. In case you have any questions or suggestions, then please depart us a remark under.

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

How to Start Dropshipping Business in India and Make Money Through it in 2020

If you're planning on beginning a dropshipping business in India, the time is correct now. Ecommerce or shopping for stuff on the Internet is...

An Internship Guide about DRDO

Defense Research Development Organization (DRDO) provides an internship to graduates and submit graduate college students. If you're on the lookout for a profession in DRDO...

How to Become a Pilot: Eligibility, Training, Study & Salary

Every little one dreamt of flying. Some wished to fly as passengers whereas others wished to grow to be pilot, taking plane hovering into...

10 Best Online Money Transfer Apps & e-Wallets in India

There was a time when sending cash from one place to a different concerned standing in lengthy financial institution/publish workplace queues, patiently awaiting your...

Recent Comments