mykm47
Forum Replies Created
-
Forum: Plugins
In reply to: [Contact Form 7] Remote IP incorrect – shows as our site's host IPHi,
I think the code for this form has been updated since I first found the solution a year ago, so the fix is a little different now. First you will probably need to restore the section that you edited:
$this->meta = array(
‘remote_ip’ => $this->get_remote_ip_addr(),
‘user_agent’ => isset( $_SERVER[‘HTTP_USER_AGENT’] )
? substr( $_SERVER[‘HTTP_USER_AGENT’], 0, 254 ) : ”,
‘url’ => preg_replace( ‘%(?<!:|/)/.*$%’, ”,
untrailingslashit( home_url() ) ) . wpcf7_get_request_uri(),
‘timestamp’ => current_time( ‘timestamp’ ),
‘unit_tag’ =>
isset( $_POST[‘_wpcf7_unit_tag’] ) ? $_POST[‘_wpcf7_unit_tag’] : ”,
);Next, go to this section below, and make sure it looks like this (changes are in bold):
private function get_remote_ip_addr() {
if ( isset( $_SERVER[‘HTTP_X_FORWARDED_FOR‘] )
&& WP_Http::is_ip_address( $_SERVER[‘HTTP_X_FORWARDED_FOR‘] ) ) {
return $_SERVER[‘HTTP_X_FORWARDED_FOR‘];
}That should work. Let me know if you want more help.
Forum: Plugins
In reply to: [Contact Form 7] Remote IP incorrect – shows as our site's host IPI think I have a solution. Go to the plugin editor and navigate to the following file:
contact-form-7/includes/submission.php
At around Line 134, you will find the following code
‘remote_ip’ => isset( $_SERVER[‘REMOTE_ADDR‘] )
? preg_replace( ‘/[^0-9a-f.:, ]/’, ”, $_SERVER[‘REMOTE_ADDR‘] ): ”,Replace “REMOTE_ADDR” (in bold above) with the following:
HTTP_X_FORWARDED_FOR
When you save it, it should start showing the right IP. Worked for me.