How to set up a custom capability with the Members plugin
Capabilities are a great way to limit access for specific user roles. If you're already using the Members plugin to create the roles, you can easily set up custom capabilities as well.
There are a lot of reasons to use capabilities. For me, it's especially handy when building custom plugins. By using custom capabilities, you can easily specify who can see the plugin in their WordPress admin dashboard and who can't.
You can do this by specifying the name of the capability as the third parameter of the add_menu_page function.
add_menu_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $callback = '', string $icon_url = '', int|float $position = null ): string
If you're using the Members plugin, you can just click on a role and use the 'custom capability' field. Enter the name of a custom capability and save the role. That's it!