Remove submission information on webform in Drupal

Are you like "What were they thinking?" about submission information on webforms? Do you care about the submission date, user, and of all things, ip address of the submitter? I didn't think so. Well, here is a way to get rid of that unnecessary data taking up valuable screen real estate.

Assuming you already have the webform module installed, open /sites/all/modules/webform/webform_report.inc and copy the contents of the following two functions:

theme_webform_results_submissions_header and theme_webform_results_submissions

and paste into template.php replacing theme with your current theme name. Let's say your theme is named 'zen_garden'. The functions in template.php should then be called zen_garden_webform_results_submissions_header and zen_garden_webform_results_submissions respectively.

Comment out the unwanted elements.

/**
* Override theme_webform_results_submissions_header in /sites/all/modules/webform/webform_report.inc
*/
function zen_garden_webform_results_submissions_header($node) {
  $columns = array(
    array('data' => t('#'), 'field' => 'sid', 'sort' => 'asc'),
    //array('data' => t('Submitted'), 'field' => 'submitted'),
  );
/*
  if (user_access("access webform results")) {
    $columns[] = array('data' => t('User'), 'field' => 'name');
    $columns[] = array('data' => t('IP Address'), 'field' => 'remote_addr');
  }
*/
  $columns[] = array('data' => t('Operations'), 'colspan' => 3);

  return $columns;
}

/**
* Override theme_webform_results_submissions in /sites/all/modules/webform/webform_report.inc
*/
function zen_garden_webform_results_submissions($node, $submissions) {
  global $user;

  // This header has to be generated seperately so we can add the SQL necessary
  // to sort the results.
  $header = theme('webform_results_submissions_header', $node);

  $rows = array();
  foreach ($submissions as $sid => $submission) {
    $row = array(
      $sid,
      //format_date($submission->submitted, 'small'),
    );
/*
    if (user_access('access webform results')) {
      $row[] = theme('username', $submission);
      $row[] = $submission->remote_addr;
    }
*/
    $row[] = l(t('View'), "node/$node->nid/submission/$sid");
    ...

Now the three unwanted elements should not appear. Make sure you empty the cache if you don't see results.

Note that this method can also be applied to the theme_webform_results_table_header and theme_webform_results_table functions in /sites/all/modules/webform/webform_report.inc as well. Happy overrides!

Comments

Question

Thanks for this. I am looking to create a webform survey that does not store the user information in the results, but I need all the other forms on my site to keep the user info. Is there a way to apply this to only one particular form and not all webforms on the side?

Useful

Thanks, this works nicely and will save me some time.

Syndicate

Syndicate content