You can control profile2 access with 

hook_profile2_access

Views listens to node access so you might be able to use to exclude rows from the view.

/**
 * Implements hook_profile2_access
 */
function MY_MODULE_profile2_access($op, $profile = NULL, $account = NULL) {
  if (isset($profile)) {
    // Use wrapper for field access
    $profile_wrapper = entity_metadata_wrapper('profile2', $profile);
    // Check if $account uid is set in field_invalid_users
    if(isset($profile_wrapper-&gt;field_invalid_users)){
      if(in_array($account-&gt;uid, $profile_wrapper-&gt;field_invalid_users-&gt;raw())){
        // Deny access
        return FALSE;
      }
    }
    // Example: Explicitly deny access for a 'secret' profile type.
    if ($profile-&gt;type == 'secret' &amp;&amp; !user_access('custom permission')) {
      return FALSE;
    }
    // In other cases do not alter access.
  }
}


One consideration is caching. Cache will need to vary enough to not serve the same cached content to valid and invalid users. Perhaps those pages aren't cached at all, it depends on your application.

Prevent a user from viewing another user's profile based on a field value
I'm trying to change git user's home directory using:

sudo usermod -d /home/git git


However, the response I receive is: "user git is currently logged in".
How can I logout that user, change the home directory and then login it again?

Thanks
