0

I'm trying to add a top-level menu-item to all of my users their Wordpress dashboard.

With the code I'm using the menu item only show up for me, the admin.

add_action( 'admin_menu' , 'edit_page' );


function edit_page() {
    global $menu;
    $menu[500] = array( __('Edit page'), 'manage_options', admin_url( 'post.php?post=8&action=edit' ), '', 'open-if-no-js menu-top', '', 'dashicons-screenoptions' );
}  

Tried several things like this:

if ( current_user_can('edit_files') ) {
    add_action( 'admin_menu' , 'admin_menu_wpse32975' );
}

But no luck.. so :

How do i make a custom top level dashboard menu item available for all users?

2

1 Answer 1

0

Thanks to @Aravona I found a fix!

function give_user_manage_options() {
    $role_object = get_role( '$role' );
    $role_object->add_cap( 'manage_options');
}
add_action( 'admin_init', 'give_user_manage_options');
1
  • Make sure this does not give non admin users access to things suchs as plugins - you may just want to replace manage_options in your menu setup with a lower user setting.
    – Aravona
    Sep 21, 2018 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.