How to Get the IP Address and Location of Users in WordPress

Did you know that 48% of businesses surveyed by Statista found that location data helped boost customer engagement and improved ROI? That’s a huge number, and that’s why it’s important to find out the IP addresses and locations of your users in WordPress.

However, finding out how to do it effortlessly can be challenging. You don’t need to surf the Internet now, as being a business owner myself, I have come up with a solution. I’ve built a WordPress plugin called “User IP and Location.” It is very effective because it gives the IP address and provides the location details every time someone visits your site, like the geo-coordinates and so much more.

Using this amazing plugin, you can handle and examine priceless information about your website visitors and, in this way, create smart decisions about what you offer, how you advertise and the visitors’ experience.

If you find it difficult to understand, you can trust me and follow me. Read this guide carefully to get fully involved in the details.

How to Get User IP and Location in WordPress

Here are the steps by which you can get the user’s IP, location, and other details using the WordPress Plugin named “User IP and Location” available free of cost on the WordPress repository.

There are two ways using which you can activate this plugin. 

  • Get the plugin files from the WordPress store or,
  • Log in to your WordPress admin panel and install from there. 
Plugin Named “User IP and Location”

We’ll follow the second option. After logging in, you have to search for the plugin. You can do this by going to “Plugins > Add New”. Then, type the plugin’s name, “User IP and Location”, and click on the correct result option.

Search for the Plugin

Now, you must select that plugin and click the “Install Now” button. After installing it, you will activate it by clicking “Activate Now”.

Yes, that’s it. The plugin is installed on your WordPress site, and you can use it in your posts, pages, and widgets for custom post types. It all depends on you. 

Here are the shortcodes for accessing various information through this plugin:

  • User IP: [userip_location type=ip]
  • User City: [userip_location type=city]
  • User Region: [userip_location type=region]
  • User Country: [userip_location type=country]
  • User Country Code: [userip_location type=countryCode]
  • Latitude: [userip_location type=lat]
  • Longitude: [userip_location type=lon]
  • Timezone: [userip_location type=timezone]
  • ISP: [userip_location type=isp]
  • Flag: [userip_location type=’flag’ height=’auto’ width=’50px’]

As soon as you fill in the necessary shortcode details, as shown in the picture above, the software will present the information which your readers might need.

Showing User’s Details on Frontend

Pro tips: You can use these shortcodes and execute specific actions based on the users’ information on your website. On the other hand, this may require an extra plugin or writing down some PHP code.

Code Snippets for Getting User IP

Alternatively, if you are not comfortable with the “User IP and Location” plugin, you can use the PHP script to display users’ IP addresses on your website.

The code is very user-friendly. All you have to do is install the “Code Snippets” plugin in the blog and copy the code below.

If you keep these codes in the “Code Snippets” plugin, then to give an IP address to people who come to your site, you just need to use the shortcode [show_ip].

Generally, I wouldn’t recommend the “Code Snippets” method because it only provides you with the visitors’ IP addresses.

A Few More Plugins for Getting User IP Details

Besides the “User IP and Location” plugin, here are a few plugins you can use on your WordPress blog or website.

1. Show IP Addresses

Show IP Address

Though the plugin has not been tested against the latest three major WordPress updates, it is working perfectly, displaying the user’s IP address. It only shows the user’s IP address on the front end, so if you need more details on the IP address, I wouldn’t encourage using this plugin.

While achieving your primary target is to use the IP address for your blog, you may want to try it. You can also develop your user-monitoring plugin/system using geo-IP location APIs available on the market.

2. Show Visitor IP

Show Visitor IP

This plugin works the same way as User IP and Location but doesn’t have features like the one I mentioned above. The features it might lack include the user’s timezone, ISP, etc.

Another thing I didn’t like about this plugin was that when I used it on my website, which is hosted with Cloudflare, it displayed my hosting IP instead of the visitors’ IP addresses.

Nonetheless, it is among the most installed plugins, and it can work perfectly for your website as long as you aren’t using Cloudflare on your blog.

Wrapping Up!

So, we already know how important it is for businesses to find their users’ location data. However many businesses do not know how to retrieve this data and use it for making data-driven decisions. I have tried to explain how to get user IP details in WordPress and show it on the frontend. 

You can use any method I discussed, but if you’re unsure about PHP and other programming languages, you can use plugins. They are much easier to handle and you can do conditional things using it.

If you have any plugins concerns, please contact us at [email protected] or leave your questions in the comments section below. 

Sunny Kumar

Number of posts: 145

Hi, I'm Sunny Kumar, a passionate tech enthusiast and a blogger from New Delhi, India. With a degree in IT from IIT-D and expertise in SEO, Cloud Computing, Telecom & Networking, and CEH, I specialize in various technical fields, including SEO, WordPress Development, and PC Building. And being a proficient WordPress user, I’m dedicated to delivering quality content and a remarkable user experience.

Leave a Comment