Created
February 20, 2015 19:37
-
-
Save AlexanderPoellmann/18ce0eaec928b3c82580 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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