Monday, September 10, 2012

Remove IP Address Tracking in Webform Submissions

The client wanted the ability to create web forms and receive submissions in their Drupal 6 website, but they aren't allowed to collect information about users. The Webform module is a great solution, but by default they collect the user's IP Address.

I wrote a simple custom module that removes the IP Address from the user's submission before the submissions is  saved. It also works for the Drupal 7 version of Webform.

<?php

//hook_webform_submission_presave
function MODULENAME_webform_submission_presave($node, &$submission) {
 
 //Removes the IP address from submissions before saving to the database
 $submission->remote_addr = NULL;
}


Simply replace 'MODULENAME' above with the name of your custom module and create a .info file specific to the version of Drupal you want to use.

If you are new to module development, you can download this module for Drupal 6 or 7 at https://github.com/weekbeforenext/webform-no-ip.

No comments:

Post a Comment