Function: sanitize_user_object

sanitize_user_object( object | array $user, string $context )

Sanitize every user field.

If the context is 'raw', then the user object or array will get minimal santization of the int fields.

Parameters

Name Type(s) Default Value Description
$user object | array

The User Object or Array

$context string 'display'

Optional, default is 'display'. How to sanitize user fields.

Returns

object | array

The now sanitized User Object or Array (will be the same type as $user)

WordPress Developer Newsletter

Stay on top of the latest WordPress API changes, developer tool updates, security alerts and more.