Force profile2 field display based on current user's role I am using the profile2 and the profile2 page modules. I have 2 profiles called user and advanced_user and corresponding roles associated to them. The advanced_user has more fields available in his profile.

The problem: when I strip an advanced_user of his role (aka demote him to user), the extra fields that he previously filled in his profile form remain in his profile page and so is the "Advanced User" title. How can I remove the additional information that was added in the advanced profile?

Note: I wouldn't mind if the extra fields' information was kept stored (so that if I ever "promote" her again she would have the fields already populated) but I definitely want to keep them from showing in the user's profile page.
Try implementing hook_profile2_view_alter(). Below is a sample code:

/**
 * Implements hook_profile2_view_alter().
 */
function example_profile2_view_alter(&amp;$build) {
  global $user;
  $rid = &lt;advance_user_role_id&gt;;

  if (!array_key_exists($rid, $user-&gt;roles)) {

    $advance_fields = array(); // List of field ID's that should only be displayed
                               // for advance users.

    foreach (element_children($build) as $id) {
      if (in_array($id, $advance_fields)) {
        $build[$id]['#access'] = FALSE;
      }
    }
  }
}