show custom plugin menu for custom user role user in wordpress

Solution:1

add custom capabilities to your plugin menu

$result = add_role('test_client', 'Test_client', 
    array(
    // Dashboard
    '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' => false, // Allows user to edit others posts not just their own
    'create_posts' => false, // Allows user to create new posts
    'manage_categories' => false, // Allows user to manage post categories
    'publish_posts' => false, // Allows the user to publish, otherwise posts stays in draft mode
    'manage_options' => false,
'custom_capability_name'=>true,
    )
    );

after that add

$role= get_role('test_client');
$role->add_cap('custom_capability_name');

finally change in your admin menu ‘manage_option’ to your ‘cusotom_capability_name’

Solution:2

For many websites, there probably isn’t much need to customize navigation. However, if you happen to run a website with multiple user types and access privileges, menu customization is a must.

Here are some of the reasons you may want to do this:

  • You offer members-only access to certain pages, content, and personal profile pages.
  • You accept guest posts and want to give them an easy way to log in without having to show a Login button to other visitors.
  • You have multiple user types that visit your website and you need to restrict access to certain parts of the navigation based on the role they play (i.e. administrator, editor, contributor, customer, etc.)
  • You run a forum or other discussion board and want to give logged-in users access to the private discussion area.
  • You want to include a registration link only to users who are not logged in or otherwise have access to your website.

If you’re looking for some simple tools and pointers on how to hide or show different parts of your WordPress menu to certain individuals, keep reading or jump ahead using these links: