You are here

function _pcp_check_user_field_access in Profile Complete Percent 7

Check is the user has access to the field.

Parameters

Array $fields: Field names which are used in complete profile.

Return value

Array Field names after removing user restricted fields.

1 call to _pcp_check_user_field_access()
pcp_get_complete_percentage_data in ./pcp.module
Get the profile complete percentage data for a given user.

File

./pcp.module, line 650
Allows users with valid permissions to tag profile fields (core fields or Profile2 fields) for a users profile to be considered complete.

Code

function _pcp_check_user_field_access($fields, $user_roles) {
  foreach ($fields as $field_key => $field_name) {
    $user_field_info = field_info_field($field_name);

    // Get list of user field access by user_role_field module.
    if (isset($user_field_info['settings']['user_role_field'])) {
      $user_field_access = $user_field_info['settings']['user_role_field'];
      $user_access_roles = array_intersect($user_field_access, $user_roles);
      if (empty($user_access_roles)) {
        unset($fields[$field_key]);
      }
    }
  }
  return $fields;
}