Skip to content

Instantly share code, notes, and snippets.

@jgalea
Last active December 19, 2015 16:19
Show Gist options
  • Save jgalea/5982726 to your computer and use it in GitHub Desktop.
Save jgalea/5982726 to your computer and use it in GitHub Desktop.
Adds a capability to an existing role.
<?php
function add_capability() {
// gets the author role
$role = get_role( 'author' );
// This only works, because it accesses the class instance.
$role->add_cap( 'edit_others_posts' );
}
add_action( 'admin_init', 'add_capability');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment