public function is_valid_save_conditions($user_id)
{
$valid = true;
$user = get_userdata($user_id);
if (empty($user->roles)) {
return;
}
// Check user role
if (!empty($this->settings['show_on']['role'])) {
$allowed_roles = (array) $this->settings['show_on']['role'];
// array_shift removed the returned role from the $user_profile->roles
// $roles_to_shift prevents changing of the $user_profile->roles variable
$roles_to_shift = $user->roles;
$profile_role = array_shift($roles_to_shift);
if (!in_array($profile_role, $allowed_roles)) {
$valid = false;
}
}
return $valid;
}