Support » Plugin: Contact Form 7 Dynamic Text Extension » Is it possible to get remote IP address in a hidden field?

  • Hi,

    I need to create a hidden field which records the IP address of the visitor.

    The reason is, I am using this together with a plugin which stores all of the captured CF7 fields efficiently in a database table. It can only record form fields, not email fields, so I cannot use the remote_IP field which CF7 offers.

    So I am trying to work out if I could create a hidden field which uses the PHP variable, $_SERVER[‘HTTP_CLIENT_IP’], or something similar. I am comfortable with simple PHP, but this is beyond my knowledge.

    (I am aware that users can spoof their IP address in this context but this is not a security issues in this case.)

    I don’t necessarily need a complete answer, but any tips or pointers would be really helpful.


Viewing 3 replies - 16 through 18 (of 18 total)
  • Were any of you able to do what you were trying to do?

    I’m trying to send the following to my CRM:


    Not via email since I am using a CRM.

    I looked into the hidden field plugin but when I added the tags that have been suggested here and in other places it doesn’t work. When I do the mapping I see the hidden fields I created but nothing gets passed when I submit the lead. So far these are the different tags I have tried with no luck:

    [hidden CF7_GET key=’_remote_ip’]
    [hidden “_remote_ip”]
    [dynamichidden useripnr id:useridnr readonly “CF7_GET key=’_remote_ip’”]

    Let me know if anyone has been able to figure this out please.


    I found this thread searching for a similar problem (capture IP, User-Agent). The proposed solutions above did not work for me too. I use this plugin to save form data in database. It already captures IP address, so here’s my solution to add User-Agent:

    1) Create a custom short-code in theme functions.php

    function please_get_useragent_func( $atts ) {
    return esc_html( substr( $_SERVER[‘HTTP_USER_AGENT’], 0, 254 ) );
    add_shortcode( ‘please_get_useragent’, ‘please_get_useragent_func’ );

    2) In your Contact Form add this line:

    [dynamichidden useragent “please_get_useragent”]

    3) Go to to see submitted data.

    Have been struggling with this for a while too especially as I’m not a PHP coder.

    Eventually I managed to find out that using the above method by @caspicasoft, but instead using code to get the client IP, it worked perfectly and I was able to submit the client IP to a CRM (CF7 to Zoho Integration plugin).

    I managed to find the following code online to fetch IP address (not sure if the whole code is needed):

    function getRealIpAddr()
        if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
        elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
        return $ip;

    Then I created the shortcode like this:

    add_shortcode( 'getRealIpAddr', 'getRealIpAddr' );

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘Is it possible to get remote IP address in a hidden field?’ is closed to new replies.