Profile Theming Question

Joined: 02/17/2008

I decided that I wanted to create (copy the G&G) a custom profile theme to use on our website. I have followed the instructions laid out in the Mustard Seed video Podcast and have made some excellent progress.

But here is my problem, we have a few fields that are private contact info fields. Fields that only our admins are supposed to see. (phone numbers, how the heard about us ect.)

However, when I theme the user profile, using the

<?php
print $account->profile_private_field_here
?>
will show this field to everyone, even if the person viewing the profile does not have the permissions to view it.

Is there a way to use an if/else statement that would only print this section when users with a certain roles are logged in and not for the general public?

Thanks Guys
Jason

Joined: 10/18/2008
Maybe: if

Maybe:

if (in_array('certain_roles', $user->roles)):
   print $account->profile_private_field_here;
endif;

/ * Begin Signature */
It's a strange thing about determined seekers-after-wisdom that, no matter where they happen to be, they'll always seek that wisdom which is a long way off. Wisdom is one of the few things that looks bigger the further away it is.

Joined: 02/17/2008
Thanks, I'll give that a

Thanks, I'll give that a try.

jason

G&G Podcast Host
Matt Farina's picture
Joined: 06/01/2006
is_array()

Don't forget to check if $user->roles is an array. There are times where it isn't and you'll end up with a log full of errors from this.

Instead, try something like:

if (is_array($user->roles) && in_array('certain_roles', $user->roles)):
   print $account->profile_private_field_here;
endif;

Matt Farina
Geeks and God Former Co-Host
www.mattfarina.com