I want to add a link to the header of a particular views page that basically says, if you're admin or another specified role, you can see this link. I don't know php well enough to figure this out. I can't figure out the right php statement. Can anyone help? I'd really appreciate it.

Comments

peterjlord’s picture

The following works for adding an image (ie image is content type name) in th header / footer of view

<?php
if (user_access('create image content')) {
  $options=array();
  $options['html'] = TRUE;
  $options['attributes'] = array('class' => 'plus', 'title' =>t('Upload an Image'));
  $options['query'] =  drupal_get_destination();
  $link = l("<span>Upload An Image</span>", 'node/add/image',  $options);
echo <<<EOD
<div class="create-image-link">$link</div>
<br class="clearboth" />
EOD;
}

Could also use

<?php
  global $user;

  if($user->uid == 1 ) {
    // Do something for admin
  }

mikou’s picture

Thanks for this. How would you do if you have two link ?

peterjlord’s picture

Not sure what you mean two links. Could you elaborate ?