Check for privacy whilst printing profile field
unxposed - October 30, 2008 - 23:57
| Project: | Profile Privacy |
| Version: | 6.x-1.2 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
In my user-profile.tpl.php file I'm not using the $content variable, but instead printing each profile variable individually like so:
<?php if ($account->profile_phone_number != '') { ?>
<dt>Phone number</dt><dd><?php print t('%phone', array('%phone' => $account->profile_phone_number)); ?></dd>
<?php } ?>I'm guessing because the php is only asking if the field is also private before it prints?
Is this the case, how would I add check to see if it's private?
Thanks!!

#1
Profile Privacy actually takes a somewhat odd approach in preventing profile module from printing certain data. Because there's no check in profile module to check for privacy, Profile Privacy actually *deletes* any private data before profile module renders the fields. Profile module then just assumes the user didn't enter a value and doesn't print anything.
So for your theming, you shouldn't need to do any additional work since any private fields will be removed entirely already. You can also check $account->private_[name_of_field] though, which will be set to TRUE if that particular field has been marked private.
#2
Also... in your testing you might notice that all the fields always seem to be showing up. If you have "administer users" privilege (user #1 will always have this permission), no data will be hidden.
#3
Ahhhh, #2 was the issue : ) silly me!
Good to know how it all works though, thanks for taking the time to respond!
#4
#5
Automatically closed -- issue fixed for two weeks with no activity.