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
Please 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
edit.php
allows 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