WordPress Version: 3.7
/**
* Sanitize every user field.
*
* If the context is 'raw', then the user object or array will get minimal santization of the int fields.
*
* @since 2.3.0
* @deprecated 3.3.0
*
* @param object|array $user The User Object or Array
* @param string $context Optional, default is 'display'. How to sanitize user fields.
* @return object|array The now sanitized User Object or Array (will be the same type as $user)
*/
function sanitize_user_object($user, $context = 'display')
{
_deprecated_function(__FUNCTION__, '3.3');
if (is_object($user)) {
if (!isset($user->ID)) {
$user->ID = 0;
}
if (!is_a($user, 'WP_User')) {
$vars = get_object_vars($user);
foreach (array_keys($vars) as $field) {
if (is_string($user->{$field}) || is_numeric($user->{$field})) {
$user->{$field} = sanitize_user_field($field, $user->{$field}, $user->ID, $context);
}
}
}
$user->filter = $context;
} else {
if (!isset($user['ID'])) {
$user['ID'] = 0;
}
foreach (array_keys($user) as $field) {
$user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context);
}
$user['filter'] = $context;
}
return $user;
}