Codex tools: Log in
Contents |
Whether the current user has a certain capability. See: Roles and Capabilities.
Do not pass a custom role name to current_user_can(), as this is not guaranteed to work correctly. Instead, you may wish to try the check user role function put together by AppThemes.
<?php current_user_can( $capability, $args ); ?>
if ( current_user_can('moderate_comments') ) {
echo 'The current user can moderate comments';
}
if ( current_user_can('edit_post', 123) ) {
echo 'The current user can edit post 123'.
}
Since: 2.0.0
current_user_can() is located in wp-includes/capabilities.php.