admin管理员组文章数量:1130349
I've created a new user role(based on shop manager) with user role editor, i need to show a custom plugin for this role.
Thanks
$user = wp_get_current_user();
if ( in_array( 'custom_role', (array) $user->roles ) ) {
//The user has the "custom" role
add_action( 'some_menu', 'my_plugin_menu' );
}
function my_plugin_menu() { add_options_page('My Plugin Settings', 'My Plugin', 'manage_options', 'my-plugin-settings', 'my_plugin_admin_page'); }
I've created a new user role(based on shop manager) with user role editor, i need to show a custom plugin for this role.
Thanks
$user = wp_get_current_user();
if ( in_array( 'custom_role', (array) $user->roles ) ) {
//The user has the "custom" role
add_action( 'some_menu', 'my_plugin_menu' );
}
function my_plugin_menu() { add_options_page('My Plugin Settings', 'My Plugin', 'manage_options', 'my-plugin-settings', 'my_plugin_admin_page'); }
Share
Improve this question
edited Dec 4, 2018 at 7:03
Eugenio Chessa
asked Dec 3, 2018 at 14:31
Eugenio ChessaEugenio Chessa
111 bronze badge
1
- you could relaize this kind of behaviour with the help of a plugin aka restrict user access. try one of these (not all are fitting your needs, but the first two and some others should do, what you are looking for) – honk31 Commented Dec 4, 2018 at 17:54
1 Answer
Reset to default 0You can try something like this
if ( is_myrole() ) { add_action( 'some_menu', 'my_plugin_menu' ); }
function my_plugin_menu() { add_options_page('My Plugin Settings', 'My Plugin', 'manage_options', 'my-plugin-settings', 'my_plugin_admin_page'); }
I've created a new user role(based on shop manager) with user role editor, i need to show a custom plugin for this role.
Thanks
$user = wp_get_current_user();
if ( in_array( 'custom_role', (array) $user->roles ) ) {
//The user has the "custom" role
add_action( 'some_menu', 'my_plugin_menu' );
}
function my_plugin_menu() { add_options_page('My Plugin Settings', 'My Plugin', 'manage_options', 'my-plugin-settings', 'my_plugin_admin_page'); }
I've created a new user role(based on shop manager) with user role editor, i need to show a custom plugin for this role.
Thanks
$user = wp_get_current_user();
if ( in_array( 'custom_role', (array) $user->roles ) ) {
//The user has the "custom" role
add_action( 'some_menu', 'my_plugin_menu' );
}
function my_plugin_menu() { add_options_page('My Plugin Settings', 'My Plugin', 'manage_options', 'my-plugin-settings', 'my_plugin_admin_page'); }
Share
Improve this question
edited Dec 4, 2018 at 7:03
Eugenio Chessa
asked Dec 3, 2018 at 14:31
Eugenio ChessaEugenio Chessa
111 bronze badge
1
- you could relaize this kind of behaviour with the help of a plugin aka restrict user access. try one of these (not all are fitting your needs, but the first two and some others should do, what you are looking for) – honk31 Commented Dec 4, 2018 at 17:54
1 Answer
Reset to default 0You can try something like this
if ( is_myrole() ) { add_action( 'some_menu', 'my_plugin_menu' ); }
function my_plugin_menu() { add_options_page('My Plugin Settings', 'My Plugin', 'manage_options', 'my-plugin-settings', 'my_plugin_admin_page'); }
本文标签: capabilitiesEnable plugins for a specific user role
版权声明:本文标题:capabilities - Enable plugins for a specific user role 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749130086a2320435.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论