Wrong IP address detected
-
The IP address is invalid for hosts with certain caching systems setup or a CDN. Can we get an option to use “X-Real-IP HTTP header” or something similar?
-
We have this filter available that you could tap into:
update_user_meta( $user_id, '_bprwg_ip_address', apply_filters( '_bprwg_ip_address', $_SERVER['REMOTE_ADDR'] ) );Something like this would work fine:
function advantechmsp_ip_address( $ip_address ) { // Return the "X-Real-IP HTTP header" value here. } add_filter( '_bprwg_ip_address', 'advantechmsp_ip_address' );That would override our default value.
I am not sure how to use this. Tried it as a php snippet (basically a custom function.php) but it still returns the server’s address instead of my own.
I really do appreciate your help BTW 🙂
What code are you using exactly?
function advantechmsp_ip_address( $ip_address ) { update_user_meta( $user_id, '_bprwg_ip_address', apply_filters( '_bprwg_ip_address', $_SERVER['REMOTE_ADDR'] ) ); } add_filter( '_bprwg_ip_address', 'advantechmsp_ip_address' );As a non-programmer i tend to just bash things together until it works 😛
Doing a bit too much there.
Just for quick example sake, since I don’t know offhand what global potentially provides the X-Real-IP header you’re wanting:
function advantechmsp_ip_address( $ip_address ) { return $_SERVER['X-Real-IP']; } add_filter( '_bprwg_ip_address', 'advantechmsp_ip_address' );All you need to do for this.
the
$ip_addressvariable will hold the original value we intend to save, provided by$_SERVER['REMOTE_ADDR']. However, you can return something completely different and THAT value will be saved instead. You could return “Pennywise’s Home” and that would end up being saved as the user meta. Sorry, watched Chapter 2 tonight :D.So, back on topic, whatever provides the IP you’re intending to use, is what should be returned.
That said, since we only use the IP address for some rudimentary location indication, during the moderation process, and delete the saved value after they’ve been approved, not sure how useful this is actually going to be to you. We added the deletion of the meta for GDPR purposes.
The use is simply to ban trolls. I’ll give it a shot in a minute.
How was CH. 2? Will be going to see it next week.
Hrm, still the wrong IP address. I wonder if the snippet is running properly. I’ll keep whacking at it.
best guess i have is that it’s not running at all.
Hrm, still can’t get it to stick. other snippets work so not sure. Where in the plugin is the IP address called so I can attempt to edit it there (not a permanent solution but a good test).
If you want to take a look it is here: hellsbasement.info-
This reply was modified 6 years, 7 months ago by
PhilipTech.
Ok, no worries. The issues was a misconfigured nginx on the backend. Our host fixed it 🙂
resolved
Awesome to hear you got this worked out in the end, I was running out of ideas 😀
-
This reply was modified 6 years, 7 months ago by
The topic ‘Wrong IP address detected’ is closed to new replies.