Function: sanitize_user_field

sanitize_user_field( string $field, mixed $value, integer $user_id, string $context )

Sanitize user field based on context.

Possible context values are: 'raw', 'edit', 'db', 'display', 'attribute' and 'js'. The 'display' context is used by default. 'attribute' and 'js' contexts are treated like 'display' when calling filters.


Name Type(s) Default Value Description
$field string

The user Object field name.

$value mixed

The user Object value.

$user_id integer

User ID.

$context string

How to sanitize user fields. Looks for 'raw', 'edit', 'db', 'display', 'attribute' and 'js'.



Sanitized value.

WordPress Developer Newsletter

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