Skip to content

Instantly share code, notes, and snippets.

@mauriciogofas
Forked from jgalea/add-capability.php
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save mauriciogofas/f5d0926a80889ee3fe89 to your computer and use it in GitHub Desktop.

Select an option

Save mauriciogofas/f5d0926a80889ee3fe89 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