Get User's Capabilities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get user's capabilities. | |
* | |
* @param int|WP_User $user The user ID or object. Default is the current user. | |
* | |
* @return array The user's capabilities or empty array if none or user doesn't exist. | |
*/ | |
function km_get_user_capabilities( $user = null ) { | |
$user = $user ? new WP_User( $user ) : wp_get_current_user(); | |
return array_keys( $user->allcaps ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where do i have to upload this file?