Add edit link to a view for admins only I have created a view in Drupal 7 that uses the node's content for display. I would like to add an edit link to this view that only displays if you are an administrator viewing this page. I know how to do this if I am using fields as the display type but not when the display type is set to content. How do I accomplish this?
You can implement hook_field_attach_view_alter to hide the field you've mentioned.

my_module_field_attach_view_alter(&amp;$output, $context) {
  global $user;

  // check if the content is what you want to alter
  if ($context['entity_type'] != 'node'] || $content['view_mode']=='my_display') return;

  // only user with 'administrator' role can see
  $output['my_field']['#access'] = in_array('administrator', $user-&gt;roles));
}


enter link description here