function simplify_hide_fields in Simplify 8
Same name and namespace in other branches
- 7.3 simplify.module \simplify_hide_fields()
Hide fields from all users without the 'View hidden fields' permission.
Parameters
array $fields: The array of fields to simplify within the given form.
array $form: The form in which to simplify the given fields.
7 calls to simplify_hide_fields()
- simplify_form_block_content_form_alter in ./
simplify.module - Implements hook_form_FORM_ID_alter() for block_add_block_form().
- simplify_form_block_form_alter in ./
simplify.module - Implements hook_form_FORM_ID_alter() for block_form().
- simplify_form_comment_form_alter in ./
simplify.module - Implements hook_form_BASE_FORM_ID_alter() for comment_form().
- simplify_form_node_form_alter in ./
simplify.module - Implements hook_form_BASE_FORM_ID_alter() for node_form().
- simplify_form_taxonomy_term_form_alter in ./
simplify.module - Implements hook_form_FORM_ID_alter() for taxonomy_term_tags_form().
File
- ./
simplify.module, line 523 - Hooks implemented by the simplify module.
Code
function simplify_hide_fields(array $fields, array &$form) {
// Check if current user can view the hidden fields.
$user_can_view_hidden = \Drupal::currentUser()
->hasPermission('view hidden fields');
// Check if even admin users must be simplified.
$hide_to_admin = _simplify_get_config_value('simplify_admin', 0);
// Depending on previous settings, simplify the $fields in the $form.
if (!empty($fields) && (!$user_can_view_hidden || _is_user_admin() && $hide_to_admin)) {
foreach ($fields as $field) {
simplify_hide_field($field, $form);
}
}
}