admin管理员组文章数量:1130349
I would like to add edit.php to user dashboard who registers as subscriber on a website. Code which i using is
add_action( 'admin_menu', 'remove_menus' );
function remove_menus(){
if(!current_user_can('subscriber'))
add_menu_page( 'edit.php' ); //dashboard
}
even has administrator instead subscriber didn't work
I would like to add edit.php to user dashboard who registers as subscriber on a website. Code which i using is
add_action( 'admin_menu', 'remove_menus' );
function remove_menus(){
if(!current_user_can('subscriber'))
add_menu_page( 'edit.php' ); //dashboard
}
even has administrator instead subscriber didn't work
Share Improve this question edited Dec 28, 2018 at 15:17 fuxia♦ 107k39 gold badges255 silver badges461 bronze badges asked Dec 28, 2018 at 11:53 FernaFerna 31 silver badge4 bronze badges 1 |2 Answers
Reset to default 0Please update the code as below
add_action( 'admin_menu', 'remove_menus' );
function remove_menus(){
$user = wp_get_current_user();
$role = ( array ) $user->roles;
if($role[0]==subscriber)
add_menu_page( 'edit.php' ); //dashboard
}
function add_custom_caps() {
global $wp_roles;
if ( ! isset( $wp_roles ) ) {
$wp_roles = new WP_Roles();
}
$role = get_role( 'subscriber' );
foreach ($wp_roles->get_role('editor')->capabilities as $key => $value){
$role->add_cap( $key );
}
}
add_action( 'admin_init', 'add_custom_caps');
It will clone all capability of Editor role and add them to Subscriber role
I would like to add edit.php to user dashboard who registers as subscriber on a website. Code which i using is
add_action( 'admin_menu', 'remove_menus' );
function remove_menus(){
if(!current_user_can('subscriber'))
add_menu_page( 'edit.php' ); //dashboard
}
even has administrator instead subscriber didn't work
I would like to add edit.php to user dashboard who registers as subscriber on a website. Code which i using is
add_action( 'admin_menu', 'remove_menus' );
function remove_menus(){
if(!current_user_can('subscriber'))
add_menu_page( 'edit.php' ); //dashboard
}
even has administrator instead subscriber didn't work
Share Improve this question edited Dec 28, 2018 at 15:17 fuxia♦ 107k39 gold badges255 silver badges461 bronze badges asked Dec 28, 2018 at 11:53 FernaFerna 31 silver badge4 bronze badges 1-
Welcome to WPSE, could you clarify what you actually want to add to the subscriber role. Do you want the user to see all postings because
edit.phpallows to enter the listing which holds all the posts. And what do you mean with user dashboard because Dashboard is a Tab on the Administration panel in the back-end. – Charles Commented Dec 28, 2018 at 17:34
2 Answers
Reset to default 0Please update the code as below
add_action( 'admin_menu', 'remove_menus' );
function remove_menus(){
$user = wp_get_current_user();
$role = ( array ) $user->roles;
if($role[0]==subscriber)
add_menu_page( 'edit.php' ); //dashboard
}
function add_custom_caps() {
global $wp_roles;
if ( ! isset( $wp_roles ) ) {
$wp_roles = new WP_Roles();
}
$role = get_role( 'subscriber' );
foreach ($wp_roles->get_role('editor')->capabilities as $key => $value){
$role->add_cap( $key );
}
}
add_action( 'admin_init', 'add_custom_caps');
It will clone all capability of Editor role and add them to Subscriber role
本文标签: pluginsWant to add post to user dashboard
版权声明:本文标题:plugins - Want to add post to user dashboard 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749062117a2310260.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


edit.phpallows to enter the listing which holds all the posts. And what do you mean with user dashboard because Dashboard is a Tab on the Administration panel in the back-end. – Charles Commented Dec 28, 2018 at 17:34