0

I'm trying to find out how to make a direct link from content profile node view/edit page to it's account page.

As an admin role when I check somebody's profile node I sometimes also need to check his/her account. So it would be much easier if I can make a direct link.

I need this link to be visible only to Admin role. Is there any way to make it?

0

Quick and easy/dirty on the view page at least, in your node template for your content profile type, let's assume it is node-profile.tpl.php, you could add something like

<?php if (user_access('administer users') && $page): ?>
  <?php print l('User Account For This Profile', 'user/' . $node->uid);
<?php endif; ?>

wherever you wanted that link. If you want it on the teasers of the node as well, eg, if the profiles are listed in a view or on the front page, etc, just take out the && $page otherwise this will only show up in the full node pages. You can also pick any permission you want, I just grabbed the first one that made sense to me :)

ADDITION: if you actually have a role called 'Admin' you can check for it like this:

 <?php 
   global $user;
   if (in_array('Admin',array_values($user->roles)) && $page) {
      print l('User Account For This Profile', 'user/' . $node->uid);
   }
 ?>
2
  • and if you don't have node templates for individual types, just add $node->type=='profile' && into the if :) – Jimajamma Jul 17 '12 at 20:10
  • Thanks for your detailed explanation. It perfectly works for my need :) – chinita7 Jul 18 '12 at 2:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.