我想删除一个贡献者角色的插件,或者只是让它不可访问。我有一个类似情况的代码:
add_filter( \'option_active_plugins\', \'disable_logged_in_plugin\' );
function disable_logged_in_plugin( $plugins ) {
// The \'option_active_plugins\' hook occurs before any user information get generated,
// so we need to require this file early to be able to check for logged in status
require (ABSPATH . WPINC . \'/pluggable.php\');
// If we are logged in, and NOT an admin...
if ( current_user_can(\'contributor\') & !is_admin() ) {
// Use the plugin folder and main file name here.
// is used here as an example
$plugins_not_needed = array (\'/metabox/meta-box.php\');
foreach ( $plugins_not_needed as $plugin ) {
$key = array_search( $plugin, $plugins );
if ( false !== $key ) {
unset( $plugins[ $key ] );
}
}
PHP return $plugins;
}
我对php没有任何经验,但我如何理解这个问题,因为他们在管理区内?(我允许他们注册和发布,但他们不是管理员)。
如果贡献者在管理区域内,我如何关闭他们的特定插件?