Last active
October 5, 2021 23:24
-
-
Save hegemanjr/b58a6d54bb94121ae36a84f63dac4ee6 to your computer and use it in GitHub Desktop.
WordPress - Create limited site owner role
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 | |
add_action('after_setup_theme', function(){ | |
if(!get_option('soes_roles_created')){ | |
$site_owner_caps = get_role('administrator')->capabilities; | |
$unwanted_caps = array( | |
'activate_plugins' => true, | |
'delete_plugins' => true, | |
'install_plugins' => true, | |
'update_plugins' => true, | |
); | |
$site_owner_caps = array_diff_key($site_owner_caps, $unwanted_caps); | |
add_role('site_owner', 'Site Owner', $site_owner_caps); | |
update_option('soes_roles_created', true); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment