Support » Fixing WordPress » finding, tracking, and storing user IPs

  • I am sure this is a really easy question but I’m not finding any answer: I want to know and follow the IP address of my site visitors across pages.

    Specifically, I have an email subscribe plugin that verifies users by IP. And an event registration program that I will use to ask customers at purchase to opt-in to emails.

    The registration program doesn’t store IPs in the db, so I need to be able to work the verification behind the scenes when I put the email addy in the subscriber table.

    I thought I’d just do something like session_start() and follow $_SESSION['ip'] on the PayPal return trip. But I’m not even getting the $_SESSION part to work.

    Please point me in the right direction. thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi there!

    I assume that you’re aware that this method of user validation can be bad. Most IP addresses are DHCP which means they will change. Some DHCP leases last months, some last days. But the address almost always changes at some point.

    You can probably easily store the IP address using the user metadata. It’s very easy, just call add_user_meta.

    BUT if you’re doing this without user info (or they’re not logging in), then this isn’t an option.

    Yes I realize the addresses most likely will change. I don’t think it will cause any problems. Here’s a long-winded explanation:

    I am using a subscription plugin that stores the IP of someone who clicks the subscribe button on my site, and then seems to verify the IP when that person then verifies via email. The DB table for this plugin shows both IPs, and I assume it is checking them against each other. I don’t know that it matters much after that instant of verification.

    I am also using a registration plugin for paid events, and when folks sign up for an event I am asking them if they want to subscribe to the emails as well. If they say yes, my intent was simply to store the email from that user in the subscriptions DB table, as if it had gone through the email verification process (two matching IPs).

    But the registration plugin doesn’t record IP addresses. So I wanted to somehow record them myself – in session variables so once a payment was made, and the user returned to the site from Paypal I could include their current IP address in the subscriptions DB table. Since the customers aren’t actually registered “users” of the site, the use of user meta-data isn’t an option.

    I suppose I could just plug in dummy variables into the table, but I really thought it would be worthwhile to know the actual IP at time of signup, especially if someone claimed later not to have done so.

    I thought this capture and recording of IP would be a very simple thing, but I’m not getting it. Am I really off base here?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘finding, tracking, and storing user IPs’ is closed to new replies.