Skip to content

Instantly share code, notes, and snippets.

@AlexanderPoellmann
Created February 20, 2015 19:37
Show Gist options
  • Save AlexanderPoellmann/18ce0eaec928b3c82580 to your computer and use it in GitHub Desktop.
Save AlexanderPoellmann/18ce0eaec928b3c82580 to your computer and use it in GitHub Desktop.
<?php
/**
* Update Teacher capabilities
* (synch with Author caps)
*
* @return void
**************************************************/
function update_teacher_caps() {
// get roles
$author = get_role('author');
$teacher = get_role('teacher');
// get capabilities
$author_caps = $author->capabilities;
$teacher_caps = $teacher->capabilities;
// check whether we have to update the teacher role
if ( is_array($author_caps) AND is_array($teacher_caps) AND $author_caps == $teacher_caps ) {
// merge capabilities
$caps = array_merge( $author->capabilities, $teacher->capabilities );
// remove old role
remove_role('teacher');
// re-add updated role
add_role( 'teacher', 'Teacher', $caps );
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment