plugins – adding new role with custom capability


I am trying to add new role with custom capability here is what I have done so far :

add_role('event_manager',__( 'Event Manager'),array(
        'read'         => true,
        'create_posts' => true,
        'my_custom_cap'   => true,


the new role have been added successfully and its working but when I am logged in with that custom role I can only see admin bar without having access to wp-admin.
based on the custom role I am adding new admin menu inside wp-admin with this code

function my_custom_event(){
   if (current_user_can( 'my_custom_cap' )){ // admin actions
       add_action('admin_menu', 'my_custom_plugin_menu');

my issue:

  • I don’t have access to the wp-admin to use my new admin menu
sdx11 2 years 2021-03-31T08:36:19-05:00 0 Answers 0 views 0

Leave an answer