How to get IP addresses from WordPress comments & contact forms

Last Updated: January 11, 2019 24

How to collect ip addresses from WordPress comments

A client recently asked how to find out the IP address of everyone who leaves a comment or submits a contact form on their WordPress website.

There’s a simple answer to the question, but it’s not one that most people know. The solution doesn’t even involve installing any extra plugins (apart from the plugin you are already using for the contact form). I hope this post helps other people who have the same question about their website.

WordPress comments and IP addresses

If you want to find out the IP address of everyone who comments on your WordPress posts, don’t bother looking for a plugin to do this. It’s already built into WordPress.

Simply go to the ‘Comments’ section in the WordPress admin. The IP address appears in the left hand column (titled ‘Author’) immediately underneath the commenter’s name and email address.

You’ve probably seen it dozens of time but never noticed.

Contact Form 7 and IP addresses

Contact Form 7 is the most popular free WordPress contact form plugin. It’s actively used on over 1 million websites worldwide.

I remember Contact Form 7 being quite basic a few years ago. However since then, it has been actively developed. Many new features have been added, making it a highly sophisticated contact form plugin.

One of Contact Form 7’s lesser known features is the Remote IP tag. Add the following shortcode anywhere within the Message Body section in the Mail tab in your contact form settings:

[_remote_ip]

Adding this shortcode will automatically insert the user’s IP address into the email notification that the administrator receives whenever a new form is submitted on the website.

Warning: You do NOT need to add the [_remote_ip] shortcode to the actual form. You only need to add it to the ‘Mail’ tab so that the IP address is added to the email that you receive when someone submits the form.

How to track IP addresses using Gravity Forms

Gravity Forms is the world leading premium WordPress contact form plugin. As you would expect from a paid-for plugin used on over 1 million websites, it already has this feature built in.

To insert the user’s IP address into the email notification to the administrator, add the following merge tag anywhere within the body for the email:

{ip}

You can read more on Gravity Forms’ Merge Tags page.

Katie Keith

An active member of the global WordPress community, Barn2 Co-Founder Katie loves collaborating with other plugin companies. Her articles have been published on high profile sites including WPTavern, Torque and IndieHackers. She oversees all plugin support and deals with 'Tier 2' support requests about how to use Barn2's plugins in advanced ways.

24 Comments

  1. lucy
    November 27, 2019 Reply

    why my wordpress comment only show 127.0.0.1?
    can you tell me where is the problem?

    • EJ
      December 3, 2019 Reply

      Hi, Lucy. If your WordPress site is showing the comment authors as having a localhost IP address (127.0.0.1), then this means that their client IP address is not being forwarded to your site properly. This can be due to a plugin or software that either you installed on your site or your web hosting provider has put on your site's web server. A web server PHP setting or configuration could also cause this. I suggest you contact your site's web hosting provider to assist you in isolating why your site is unable to detect the correct IP address of commment authors.

  2. Chuck
    July 10, 2019 Reply

    Hi!

    Thanks for the instruction, but it's not working for me. I cut and pasted the short code into the message body section of the mail tab, and NOT the form itself as you warned, and it's still not working. Any ideas?

    Thanks!

    • EJ
      August 17, 2019 Reply

      Hi, Chuck! Thanks for following our tutorial and sorry to get back to you only now. If the Contact Form 7 Special Mail Tag to get the form submitter's IP address isn't working, I suggest contacting Contact Form 7 Support as they would have a better idea about the possible reasons for this and how to address them.

  3. Chris
    March 28, 2019 Reply

    Will ip address tell someone's street address though? It was my understanding that up address will only tell the location of the isp and not the users street address. Is this true?

    • Katie Keith
      March 29, 2019 Reply

      No, it will only give general information such as city. You can read more here.

Please share your thoughts...

Your email address will not be published.