You are here

function webform_webform_submission_render_alter in Webform 7.4

Same name and namespace in other branches
  1. 6.3 webform.module \webform_webform_submission_render_alter()
  2. 7.3 webform.module \webform_webform_submission_render_alter()

Implements hook_webform_submission_render_alter().

File

./webform.module, line 1414
This module provides a simple way to create forms and questionnaires.

Code

function webform_webform_submission_render_alter(&$renderable) {

  // If displaying a submission to end-users who are viewing their own
  // submissions (and not through an e-mail), do not show hidden values.
  // This needs to be implemented at the level of the entire submission, since
  // individual components do not get contextual information about where they
  // are being displayed.
  $node = $renderable['#node'];
  $is_admin = webform_results_access($node);
  if (empty($renderable['#email']) && !$is_admin) {

    // Find and hide the display of all hidden components.
    module_load_include('inc', 'webform', 'includes/webform.components');
    foreach ($node->webform['components'] as $cid => $component) {
      if ($component['type'] == 'hidden') {
        $parents = webform_component_parent_keys($node, $component);
        $element =& $renderable;
        foreach ($parents as $pid) {
          $element =& $element[$pid];
        }
        $element['#access'] = FALSE;
      }
    }
  }
}