Created
January 30, 2015 06:08
-
-
Save DrewAPicture/d14460d88ac856d91287 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 | |
/** | |
* Limit plugin installations to a single authorized account. | |
* | |
* @param array $caps Meta capabailities. | |
* @param string $cap Primitive capability. | |
* @param int $user_id User ID. | |
* @param array $args Arguments. | |
* @return array Filtered meta capabilities. | |
*/ | |
function lock_down_plugin_controls( $caps, $cap, $user_id, $args ) { | |
// Keep plugins for local and staging. | |
if ( strpos( get_site_url(), '.dev' ) || strpos( get_site_url(), 'staging' ) ) { | |
return $caps; | |
} | |
// Specific user ID. | |
if ( 55 !== $user_id ) { | |
if ( 'edit_plugins' == $cap | |
|| 'update_plugins' == $cap | |
|| 'delete_plugins' == $cap | |
|| 'install_plugins' == $cap | |
) { | |
$caps[] = 'do_not_allow'; | |
} | |
} | |
return $caps; | |
} | |
add_filter( 'map_meta_cap', 'lock_down_plugin_controls', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment