Skip to Main Content

How to view or block IP addresses on WordPress

Divi: the easiest WordPress theme to use

Easily create your website with Elementor

Elementor allows you to easily create any website design with a professional look. Stop paying expensive for what you can do yourself. [Free]

If you are connected to the Internet, you have a unique identification number known as an IP address. And it's no different for your visitors (each person coming to your website also has their own unique IP address).

With good WordPress plugins and tools, you will be able to manipulate IP addresses to add features and / or restrict access to your WordPress website.

In this tutorial, I will explore both axes. That is, after reading this tutorial, you will know how you can:

  • Dynamically display each user's IP address on the front-end of your WordPress website.
  • Block users based on their IP address.

But before, if you have never installed WordPress discover How to Install a WordPress Blog in 7 Steps et How to search, install and activate a WordPress theme on your blog 

Then back to why we are here.

How to display a user's IP address in WordPress

We're going to explore IP blocking, but let's start with a use that's a bit more positive:

Using WordPress to display a visitor's own IP address.

When could this be useful? Although you can still use it as a widget fun, there are also practical uses.

For example, if you are presenting code snippets where a user needs to insert their own IP address, you can use this technique to show visitors their IP address to help them solve their problem.

Similarly, you can give instructions to visitors who must enter their IP address as part of the instructions. Once again (This approach allows visitors to find their own IP address).

Although the code for creating your own shortcode is quite simple enough, there is already a lightweight plugin called " Show IP address That does exactly what you need and nothing more.

Here's how to use it:

See also How to allow access to certain IP addresses in WordPress 

Step 1: Install, activate and view the IP address

To begin, search for " Show IP Address On your dashboard and install the free plugin. You need to look for the Keith Griffiths plugin.

Shop ip address wordperss

Once installed, there is really nothing to configure. As I mentioned (the plugin is incredibly lightweight) we are literally talking about a few lines of code.

Discover our 8 plugins WordPress to block visitors

But in the meantime, let's continue with the second step

Divi: The best WordPress theme of all time!

With over 901.000 downloads, Divi is the most popular WordPress theme in the world. It is complete, easy to use and comes with more than 62 free templates. [Recommended]

Step 2: Use a "shortcode" to display users' IPs

Once you have activated the plugin, you can use the shortcode [Show_ip] to display the IP address of a user.

Want to display a user's IP address in your WordPress sidebar? Just add the shortcode to a text widget:

Shortcode on a wordpress text widget

How to block users by IP address on WordPress

Sometimes you encounter a very specific set of bad actors on your WordPress website. It could be:

  • people who spamment your comment sections
  • those who perform DDoS attacks
  • Malicious actions ( for example: those who visit your wp login page, even with a website with private dashboard access)
  • Any other type of unwanted traffic

Part of these problems is to install a quality security plugin. Good security plugins include security measures and firewalls that will automatically block the wrong known IP addresses.

Check out our 6 Tricks to better protect your WordPress dashboard

But you might also have a situation where you need to get rid of specific IP addresses. This is what we will be talking about.

How to find the IP addresses of malicious visitors

If you already have IP addresses that you want to ban, you should go to the next section.

If you come across spam comments, finding the spammer's IP address is necessary. And WordPress actually gives you that information for every comment. All you need to do is go to the comment management page to find the IP addresses of each comment:

Comments ip addresses

Finding IP addresses for other negative actors is a bit trickier. Unless you have a specific activity monitoring plugin, your best bet is normally to dig into your hosting's access reports.

For example, if your host uses cPanel, you can download a log of all your website activity by accessing the raw access logs:

Raw cpanel access log

You can download a traffic log for each specific website that you administer. Then, using something like "Winzip", you can open the ".gz" log file. Then, open the file that is in the .gz file with Notepad or another text editor.

At this point, you can use CTRL + F to search for people who have viewed specific pages on your website.

For example, you can check if someone other than yourself has tried to access your dashboard by searching for " wp-admin " or " wp-login "

Raw access log example text search

Are you looking for the best WordPress themes and plugins?

Download the best plugins and WordPress themes on Envato and easily create your website. Already more than 49.720.000 downloads. [EXCLUSIVE]

In the screenshot above you can see that someone using Firefox tried to access my wp login page. I should probably block them since I'm using Google Chrome!

Start protecting your blog by discovering How to install WordFence security on WordPress

How to ban specific IP addresses from your WordPress site

When it comes to blocking specific IP addresses in order to prevent them from accessing your WordPress website, you have a few different ways of approaching the problem. Here are some of the most common:

  • Using the blacklist of comments. It's part of WordPress.
  • Using a plugin. As is normally the case, you can find a free WordPress plugin to help you get the job done.
  • Use the IP address blocking tool on the cPanel. A server-side option for those who host WordPress websites on hosts using cPanel.
  • Block specific IP addresses with the file..htaccess.

You can now block some IP addresses on your WordPress blog.

Discover also some themes and premium WordPress plugins  

You can use other themes and WordPress plugins to give a modern look and optimize the grip of your blog or website.

Here are some premium WordPress plugins and themes that will help you do that.

1. Bookly PRO

Bookly Pro is a premium WordPress plugin that allows you to add to your website a fully automated online reservation system. It offers a fully customizable booking form that supports different payment gateways, notifications and synchronization with Google Calendar.

Bookly pro - appointment booking and scheduling wordpress plugin

Its default configuration includes: a fFully customizable reservation form that can be used on any device, aist filterable, sortable and searchable bookings, which you can print or export to a CSV file, a nUnlimited shade of staff with individual work schedules, rates and the ability to manage their profile and booking schedule online.

You will also find a nUnlimited shadow of services that you can group into categories and set unique colors for easy viewing in Bookly Calendar, a bimportable and exportable customer base with an unlimited list of customers that displays payment statistics and internal notes on the customer.

Download | Demo | Web hosting

2. Slider Revolution

Revolution Slider is an innovative and responsive carousel WordPress plugin that displays your content beautifully. Whether it's a slider or a carousel, its visual editor drag and drop will allow you to tell for example the history of your company, to highlight your best products, your best articles and more

Slider revolution wordpress plugins create slide shows website slides

Its features are: an excellent slide creation interface, drag and drop slide design, fully responsive layout, perfect management of multimedia content, optimized performance, multilingual support, delivered with nearly 340 graphic elements, many slide show templates available, compatibility with the majority of WordPress themes, excellent customer support, support for touch screens, free and regular updates, the documentation and video tutorials available and many more.

Download | Demo | Web hosting

3. Click to WhatsApp Chat

The WordPress Click to WhatsApp Chat plugin allows WordPress customers to easily connect with the website owner or customer support using their WhatsApp account. Just one click on the WhatsApp account and it will be taken directly to your mobile WhatsApp application account with a default message. 

Click to whatsapp chat for wordpress

If the customer is on a desktop or laptop, they will be redirected to WhatsApp Web. This plugin will require the WhatsApp number and time and day, which the website owner or support team will use to discuss.

The chat button can be added to the WooCommerce product details page, which is directly related to this product.

Easily create your Online Store

Download free WooCommerce, the best e-commerce plugins to sell your physical and digital products on WordPress. [Recommended]

Download | Demo | Web hosting

Recommended Resources

Find out about other recommended resources to help you build and manage your website.

Conclusion

Here is ! That's all for this tutorial, we hope it will allow you to better control visitor access to your website. If you liked it, don't hesitate to share with your friends on your favorite social networks

However, you will also be able to consult our resources, if you need more elements to carry out your projects of creation of Internet sites, by consulting our guide on the WordPress blog creation.

But, in the meantime, tell us about your Comments and suggestions in the dedicated section.

...

This article features 0 comments

Leave a comment

Your email address will not be published. Required fields are marked with *

This site uses Akismet to reduce unwanted. Learn more about how your comments data is used.

Back To Top
15 shares
Share7
tweet2
Save6