Function: current_user_can

current_user_can( string $capability )

Whether the current user has a specific capability.

While checking against particular roles in place of a capability is supported in part, this practice is discouraged as it may produce unreliable results.

Note: Will always return true if the current user is a super admin, unless specifically denied.

Parameters

Name Type(s) Default Value Description
$capability string

Capability name.

Returns

boolean

Whether the current user has the given capability. If $capability is a meta cap and $object_id is passed, whether the current user has the given meta capability for the given object.

WordPress Developer Newsletter

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