Skip to content

Instantly share code, notes, and snippets.

@alordiel
Created July 1, 2019 14:44
Show Gist options
  • Save alordiel/653a8b719d9150f4ffa92f6ec70151b9 to your computer and use it in GitHub Desktop.
Save alordiel/653a8b719d9150f4ffa92f6ec70151b9 to your computer and use it in GitHub Desktop.
[WordPress] Add capability for single user or role
add_action( 'admin_init', 'add_theme_caps');
function add_theme_caps() {
// add single role capability
$role = get_role( 'administrator' );
$role->add_cap( 'manage_phrases' );
// add single user capability
$user = new WP_User( 4766 );
$user->add_cap( 'manage_phrases' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment