0

I want to send Client's IP address with WordPress's wp_remote_post() function. Target URL should recognize Client's IP address instead of Server's IP.

Is it possible?

Shakeel Ahmed
  • 1,526
  • 17
  • 22
  • here you have an answer how to obtain visitor's IP: http://stackoverflow.com/questions/3003145/how-to-get-the-client-ip-address-in-php – kkarpieszuk Apr 10 '15 at 14:40
  • Thanks kkarpieszuk, but read my question again, I want to forward client's ip to targeted url using in function wp_remote_post() – Shakeel Ahmed Apr 10 '15 at 14:46

1 Answers1

0

Depending on the REST service receiving the data. You could try one of the following:

Query params $response = wp_remote_get( $url . '?client_ip=' . $_SERVER["REMOTE_ADDR"] );
Headers $response = wp_remote_get( $url, [ 'headers' => [ 'client_ip' => $_SERVER[ "REMOTE_ADDR" ] ] );

jaredrethman
  • 512
  • 5
  • 16