Last active
August 29, 2015 14:21
-
-
Save arispublic/050f25a2ce1de377c2b7 to your computer and use it in GitHub Desktop.
Drupal 7: Preprocess custom fields before render it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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