• Resolved mamibe

    (@mamibe)


    Hi,

    I want to strip the last 3 digits from the IP of each entry into CFDB – German privacy laws require you to do so, actually. I thought I could easily access the field, delete the last three digits and add three zeroes. But that did not work as expected.

    // My form filter - added in functions.php
    function myFilter($formData){
        $formName = 'myform'; // change this to your form's name
        if ($formData && $formName == $formData->title) {
    
           $ip = $formData->posted_data['Submitted From']);
           $stripped = substr($ip, 0, -3);
           $ip_ano = $stripped . "000";
    
           $formData->posted_data['Submitted From'] = $ip_ano;
    
        }
        return $formData;
    }
    
    add_filter('cfdb_form_data', 'myFilter');

    But I cannot access the field this way. Most probably it gets created sometime else.

    Where can I place that modifying code to make the submitters’ IPs anonymous?

    https://www.ads-software.com/plugins/contact-form-7-to-database-extension/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Michael Simpson

    (@msimpson)

    That is handle a differently. Try this:

    function myFilter($formData){
        $formName = 'myform'; // change this to your form's name
        if ($formData && $formName == $formData->title) {
    
           $ip = $formData->ip;
           $stripped = substr($ip, 0, -3);
           $ip_ano = $stripped . "000";
    
           $formData->ip = $ip_ano;
    
        }
        return $formData;
    }
    
    add_filter('cfdb_form_data', 'myFilter');

    I think this assumes you are using CF7.

    Thread Starter mamibe

    (@mamibe)

    Splendid, that worked! Thanks a million.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to make "Submitted From" anonymous?’ is closed to new replies.