I have a custom user_profile.tpl.php page which displays a list of profile fields. I now need to hide some of these fields for people who are not logged into the site. I can't control access to the fields via the profile module as the custom user_profile.tpl.php is calling them directly and seems to be overiding the profile settings.

So how would I let logged in users see the full output of the custom user_profile.tpl.php and show non-members a different user_profile.tpl.php file with the sensitive fields removed?

Thank you.

Comments

mz906’s picture

is this what you are looking for?

global $user;

if ( $user->uid ) {
  // Logged in user
}
else {
  // Not logged in
}
gavin_s’s picture

Looks good - where do I specify a 'if not logged' in location?

mz906’s picture

global $user;

if ( $user->uid ) {
  include ('logged_in.html');
}
else {
  include ('NOT_logged_in.html');
}

does that help?

gavin_s’s picture

Hi Mz906. Thing is, if the user is logged in I want drupal to carry on and use the user_profile.tpl.php. Otherwise, if they are not logged in I want a different user_profile.tpl.php to be used. THis code does not seem to work for this scenario after substituting the relevant files in the code.

Any ideas?

gavin_s’s picture

Using snippet found here http://drupal.org/node/45774 in the custom profile page. Thanks for help.