I have only two profiles, public and registration but I have different roles and would like to add an appropriate default image for each role.

Must I create a separate profile for each role to implement this?

  • What do you mean by two profiles? In Drupal, all users have a user profile, but this is generally the same for all users, regardless of their roles. – Patrick Kenny Feb 4 '13 at 1:32
  • I mean in structure - profile types I have set up two types. One for public and one for registration. – cea Feb 4 '13 at 1:42
  • @CharlieMeany are you using the Profile2 module, or the Profile module which comes default with Drupal 7 (intended to help keep old D6 profiles alive), or something else? – areynolds Feb 4 '13 at 6:48
  • profile2 is what I am using. – cea Feb 4 '13 at 12:55
up vote 0 down vote accepted

If you want to display an image for a particular user role , say "Role1" , then in page.tpl

 <?php global $user;
  if($user->roles[2] == 'Role1')
 {
 print $logo;
 }?>

Just print the $user to get in what values your role is in the role array.

If you print $user, your role may be in this,

 [roles](
 [1] = role1
 [2] = role2
 [3] = role3
       )

So choose your role and check the condition and accordingly print the $logo however before that get the image in $logo using the image source tag.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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