php - Allow specific user manage & install plugins - WooCommerce/Wordpress
I try to allow specific user to install and manage plugins. His role is Store Manager (WooCommerce), and this is my functions:
function add_theme_caps() {
// Get & Set user ID
$shopmanager_id = 7;
$shopmanager = new WP_User( $shopmanager_id );
// Let him manage and install plugins
$shopmanager->add_cap( 'edit_plugins', true );
$shopmanager->add_cap( 'install_plugins', true );
}
add_action( 'admin_init', 'add_theme_caps');
But it's not working. How to achieve that?
Answer
Solution:
OK, so I made this in different way. There was some problem with Manager role from WooCommerce. So I decide to add this user ADMIN role, and then lower its privileges with custom code, if/else and custom redirections via functions.php.
Source