Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Can I conditionally hide properties being displayed using SPSWC:ProfilePropertyDisplayName and SPSWC:ProfilePropertyValue based on the field policy settings "Default Privacy Setting" (or the "Show To" option if "User can override" is checked) for the property? I'm using the following code to display the properties.

<tr>
    <td><SPSWC:ProfilePropertyDisplayName PropertyName="Hobbies" dir="ltr" runat="server"/>:</td>
    <td><SPSWC:ProfilePropertyValue PropertyName="Hobbies" dir="ltr" runat="server"/></td>
</tr>
<tr>
    <td><SPSWC:ProfilePropertyDisplayName PropertyName="Activities" dir="ltr" runat="server"/>:</td>
    <td><SPSWC:ProfilePropertyValue PropertyName="Activities" dir="ltr" runat="server"/></td>
</tr>
<tr>
    <td><SPSWC:ProfilePropertyDisplayName PropertyName="Allergies" dir="ltr" runat="server"/>:</td>
    <td><SPSWC:ProfilePropertyValue PropertyName="Allergies" dir="ltr" runat="server"/></td>
</tr>

This is related to another question about user profile properties.

Thanks!

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

For conditionally hiding or changing properties like this, I typically do it via jQuery on the rendered page. If you want to do it based on the privacy settings in the manner you are working now, I'm afraid that you would need to create a custom control that replaces the PropertyValue control.

share|improve this answer
    
Thanks, Mike. Using ProfilePropertyDisplayName and ProfilePropertyValue in a table (or at all) isn't a requirement; it's just a way that I found to do this. Is there another way to do this that would work based on privacy settings? If not, I'll take your suggestion as the answer and hide the rows with empty property values using JavaScript, since ProfilePropertyValue seems to output nothing if the current user can't see the property. –  Don 01001100 Jan 3 '12 at 17:02
add comment

Just a guess, but the User Profile Service should handle that for you. When the user changes the display property requests for the property will not be returned to users who do not have the rights.

Have you tried it? What were the results?

share|improve this answer
    
Thanks for the reply, Matthew. ProfilePropertyDisplayName always outputs the property display name, whereas ProfilePropertyValue outputs nothing. I don't want to leave other people viewing the profile with the impression that there is no information when the information is actually private. –  Don 01001100 Jan 3 '12 at 18:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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