0
votes

I am making a custom plugin with custom user role:

add_role('lln_assessor', 'LLN Assessor', array(

'read' => true, // true allows this capability
'edit_posts' => true, // Allows user to edit their own posts
'edit_pages' => true, // Allows user to edit pages
'edit_others_posts' => true, // Allows user to edit others posts not just their own
'create_posts' => true, // Allows user to create new posts
'manage_categories' => true, // Allows user to manage post categories
'publish_posts' => true, // Allows the user to publish, otherwise posts stays in draft mode
));

this role will be created when I activate my custom plugin.

Now, in the wp-admin or its dashboard when it logged, how can I create its own menu and page?

1

1 Answers

0
votes

Here custom_cap is custom capability added to new role and while adding new admin menu this capability is added.

  add_role('lln_assessor', 'LLN Assessor', array(

    'read' => true, // true allows this capability
    'edit_posts' => true, // Allows user to edit their own posts
    'edit_pages' => true, // Allows user to edit pages
    'edit_others_posts' => true, // Allows user to edit others posts not just their own
    'create_posts' => true, // Allows user to create new posts
    'manage_categories' => true, // Allows user to manage post categories
    'publish_posts' => true, // Allows the user to publish, otherwise posts stays in draft mode
    'custom_cap'=>true
    ));

        add_menu_page( 'Custom Menu', 'Custom Menu', 'custom_cap', 'menu-slug', 'menu_function', plugins_url( 'icon.png' ), '1.0' );

    function menu_function(){

      // do code for menu here

    }

   }