Skip to content

Instantly share code, notes, and snippets.

@kellenmace
Last active March 25, 2019 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellenmace/fc59a52454bad6aa7dedf85ccce223aa to your computer and use it in GitHub Desktop.
Save kellenmace/fc59a52454bad6aa7dedf85ccce223aa to your computer and use it in GitHub Desktop.
Get User's Capabilities
<?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 );
}
@julianojacob
Copy link

Where do i have to upload this file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment