0

I am using Contact Form 7 to collect data and send it through the CF7 to API Plugin.

For security reasons, I receive the data via email through the [wpcf7.remote_ip] tag, which I insert in the email field as per the guide.

Screen of The Email Body: Screen of The Email Body

But when I try to send the same data via API through "CF7 to API", the value is empty.

Screen of the CF7 to API setup: Screen of the CF7 to API setup

Where am I wrong?

Screen of the CF7 to API log: Screen of the CF7 to API log

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Adamo Romano
  • 1
  • 1
  • 1
  • What have you tried so far? Where are you stuck? Can you share the code you are using? – Nico Haase Sep 30 '21 at 09:26
  • I would like, but there's no code indeed. What i did is 1. Paste the tag [wpcf7.remote_ip] inside the email body 2. Add an hidden field named "aff_subid1" in the form body 3. CF7 to API recognized this field and gave it to me as an empty field in the plugin GUI (which represent the array, i guess) 4. I gave to that field wpcf7.remote_ip as value – Adamo Romano Sep 30 '21 at 09:38

1 Answers1

1

wpcf7.remote_ip is only valid in an email template because it is created/populated by the CF7 plugin when the notification mail is being processed. You will need to create your own hidden field on the form when the page is loaded which you can then use in your API listing,

add_filter('wpcf7_form_hidden_fields','add_hidden_ip_field');
function add_hidden_ip_field($fields){
  $fields['remote_ip'] = ... //get the remote IP
  return $fields;
}

NOTE: to get the request remote IP, see this answer

You can then use the field remote_ip in your API

Aurovrata
  • 2,000
  • 27
  • 45
  • Thanks so much. Are those 3 dots after $fields correct? Or just an example? If so... what value should i use instead? And maybe could you also tell me in which file of CF7 should i paste this code? Thanks again, amazing. – Adamo Romano Sep 30 '21 at 09:52
  • the 3 dots are to be replaced by the functionality to retrieve the IP....see the NOTE below – Aurovrata Sep 30 '21 at 11:38