Title: user_can
Published: April 25, 2014
Last modified: February 24, 2026

---

# user_can( int|WP_User $user, string $capability, mixed $args ): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/user_can/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/user_can/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/user_can/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/user_can/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/user_can/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/user_can/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/user_can/?output_format=md#wp--skip-link--target)

Returns whether a particular user has the specified capability.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/user_can/?output_format=md#description)󠁿

This function also accepts an ID of an object to check against if the capability
is a meta capability. Meta capabilities such as `edit_post` and `edit_user` are 
capabilities used by the `map_meta_cap()` function to map to primitive capabilities
that a user or role has, such as `edit_posts` and `edit_others_posts`.

Example usage:

    ```php
    user_can( $user->ID, 'edit_posts' );
    user_can( $user->ID, 'edit_post', $post->ID );
    user_can( $user->ID, 'edit_post_meta', $post->ID, $meta_key );
    ```

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/user_can/?output_format=md#parameters)󠁿

 `$user`int|[WP_User](https://developer.wordpress.org/reference/classes/wp_user/)
required

User ID or object.

`$capability`stringrequired

Capability name.

`$args`mixedoptional

Optional further parameters, typically starting with an object ID.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/user_can/?output_format=md#return)󠁿

 bool Whether the user has the given capability.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/user_can/?output_format=md#source)󠁿

    ```php
    function user_can( $user, $capability, ...$args ) {
    	if ( ! is_object( $user ) ) {
    		$user = get_userdata( $user );
    	}

    	if ( empty( $user ) ) {
    		// User is logged out, create anonymous user object.
    		$user = new WP_User( 0 );
    		$user->init( new stdClass() );
    	}

    	return $user->has_cap( $capability, ...$args );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/capabilities.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/capabilities.php#L1010)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/capabilities.php#L1010-L1022)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/user_can/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_User::__construct()](https://developer.wordpress.org/reference/classes/wp_user/__construct/)`wp-includes/class-wp-user.php` |

Constructor.

  | 
| [get_userdata()](https://developer.wordpress.org/reference/functions/get_userdata/)`wp-includes/pluggable.php` |

Retrieves user info by user ID.

  |

| Used by | Description | 
| [user_can_for_site()](https://developer.wordpress.org/reference/functions/user_can_for_site/)`wp-includes/capabilities.php` |

Returns whether a particular user has the specified capability for a given site.

  | 
| [WP_REST_Application_Passwords_Controller::get_user()](https://developer.wordpress.org/reference/classes/wp_rest_application_passwords_controller/get_user/)`wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php` |

Gets the requested user.

  | 
| [wp_initialize_site()](https://developer.wordpress.org/reference/functions/wp_initialize_site/)`wp-includes/ms-site.php` |

Runs the initialization routine for a given site.

  | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  | 
| [map_meta_cap()](https://developer.wordpress.org/reference/functions/map_meta_cap/)`wp-includes/capabilities.php` |

Maps a capability to the primitive capabilities required of the given user to satisfy the capability being checked.

  | 
| [wp_notify_postauthor()](https://developer.wordpress.org/reference/functions/wp_notify_postauthor/)`wp-includes/pluggable.php` |

Notifies an author (and/or others) of a comment/trackback/pingback on a post.

  | 
| [wp_notify_moderator()](https://developer.wordpress.org/reference/functions/wp_notify_moderator/)`wp-includes/pluggable.php` |

Notifies the moderator of the site about a new comment that is awaiting approval.

  | 
| [get_allowed_mime_types()](https://developer.wordpress.org/reference/functions/get_allowed_mime_types/)`wp-includes/functions.php` |

Retrieves the list of allowed mime types and file extensions.

  | 
| [get_dashboard_url()](https://developer.wordpress.org/reference/functions/get_dashboard_url/)`wp-includes/link-template.php` |

Retrieves the URL to the user’s dashboard.

  | 
| [wp_update_comment()](https://developer.wordpress.org/reference/functions/wp_update_comment/)`wp-includes/comment.php` |

Updates an existing comment in the database.

  |

[Show 5 more](https://developer.wordpress.org/reference/functions/user_can/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/user_can/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/user_can/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.3.0](https://developer.wordpress.org/reference/since/5.3.0/) | Formalized the existing and already documented `...$args` parameter by adding it to the function signature. | 
| [3.1.0](https://developer.wordpress.org/reference/since/3.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fuser_can%2F)
before being able to contribute a note or feedback.