How to store IP addresses on form entries

Created by Phil Kurth, Modified on Tue, 28 Jun 2022 at 04:25 PM by Phil Kurth

IP addresses are not stored by default as these are considered personal data according to the GDPR. Should you wish to store the IP address of the submitting user, you may do so using the af/form/entry_created action hook

add_action( 'af/form/entry_created', function ( $entry_id, $form ) {
  if ( $form['key'] === 'YOUR_FORM_KEY_HERE' ) {
    update_post_meta( $entry_id, '_af_entry_ip_address', $_SERVER['REMOTE_ADDR'] );
  }
}, 10, 2 );

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article