Skip to content

Instantly share code, notes, and snippets.

@arispublic
Last active August 29, 2015 14:21
Show Gist options
  • Save arispublic/050f25a2ce1de377c2b7 to your computer and use it in GitHub Desktop.
Save arispublic/050f25a2ce1de377c2b7 to your computer and use it in GitHub Desktop.
Drupal 7: Preprocess custom fields before render it
<?php
/**
* Hide first name & last name from user account (additional fields), on render it.
* @param type $vars
*/
function mymodule_preprocess_field(&$vars) {
if (in_array($vars['element']['#field_name'], array('field_first_name', 'field_last_name'))) {
$vars['items'] = array(); //remove the value
$vars['label_hidden'] = true; //hide the label
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment