3

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!

2 Answers 2

1

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.

1
  • 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.
    – Becca
    Jan 3, 2012 at 17:02
1

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?

1
  • 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.
    – Becca
    Jan 3, 2012 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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