Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

How to: Target List Items to an Audience

By using Web Parts that recognize audience membership, you can target items or links in a list to one or more audiences, so that only members of those audiences view the targeted items within the Web Parts. For example, in a default area called Human Resources, a site administrator or the manager of that area may choose to add a news item within the News Web Part. This item could be targeted to an audience composed of all new employees, directing them to the New Employee Benefits site.

The following example shows you how to target a list item to an audience.


   AudienceLoader audienceLoader = AudienceLoader.GetAudienceLoader();
   foreach (SPListItem listItem in list.Items)
      // get roles the list item is targeted to
     string audienceFieldValue = (string)listItem[k_AudienceColumn];

      // quickly check if the user belongs to any of those roles
     if (AudienceManager.IsCurrentUserInAudienceOf(audienceLoader,
                    // is a member
                    // not a member

See Also

Community Additions

© 2015 Microsoft