How to Add Your Plugin to the Demo Back-End

Once you’ve created your demo users, you then need to add the plugins you want to demo to the demo back-end (seen by those demo users).

This is done by adjusting the $capability parameter in the call to the WordPress “add_menu_page()” function (in the plugins you want to demo).

The “add_menu_page()” Function – and it’s “$capability” Parameter

The WordPress “add_menu_page()” function is used to add plugins to the left-hand menu displayed on WordPress back-end screens – as described here.

More specifically, if the logged-in user has the “$capability” supplied to the “add_menu_page()” function call in the plugin, then the the plugin will be added to the left-hand menu on WordPress back-end screens.  But if the logged-in user DOESN’T have that “$capability”, then plugin WON’T be added to that left-hand menu.

The “$capability” Parameter in Your Plugin Proper

Most plugins are intended to be run by the site’s “Administrator”.

And since (by default), the WordPress “Administrator” role is the only role that has the “manage_options” capability, the call to “add_menu_page()” in most plugins has $capability = “manage_options”.  For example:-


    // -------------------------------------------------------------------------
    // Add This Plugin to the WordPress Admin Left Menu...
    // -------------------------------------------------------------------------

    function add_this_plugin_to_the wordpress_admin_menu() {

        $page_title = 'My Plugin Name'       ;
        $menu_title = 'My Plugin Name'       ;
$capability = 'manage_options' ; // "Administrators" only. // This plugin will be displayed in the WordPress // back-end left-hand menu, but only if the // logged-in user is an "Adminstrator".
$menu_slug = 'myPluginsMenuSlug' ; $function = 'my_plugins_home_page' ; $icon_url = '' ; $position = NULL ; add_menu_page ( $page_title , $menu_title , $capability , $menu_slug , $function , $icon_url , $position ) ; } // ------------------------------------------------------------------------- add_action( 'admin_menu' , 'add_this_plugin_to_the wordpress_admin_menu' ) ; // -------------------------------------------------------------------------

“$capability” in the Demo Version of Your Plugin

To ensure that your demo users will see the plugins you want to demo listed in the demo back-end, you’ve got to change $capability to some capability that your demo users have.

Since (by default) all WordPress roles including “Subscriber” have the “read” capability, then in most cases setting; $capability = ‘read’ should do.  For example:-


    // -------------------------------------------------------------------------
    // Add This Plugin to the WordPress Admin Left Menu...
    // -------------------------------------------------------------------------

    function add_this_plugin_to_the wordpress_admin_menu() {

        $page_title = 'My Plugin Name'       ;
        $menu_title = 'My Plugin Name'       ;
$capability = 'read' ; // Any logged-in user should see this plugin, // no matter what their Role (so long as the // logged-in user's role has the "read" // capability).
$menu_slug = 'myPluginsMenuSlug' ; $function = 'my_plugins_home_page' ; $icon_url = '' ; $position = NULL ; add_menu_page ( $page_title , $menu_title , $capability , $menu_slug , $function , $icon_url , $position ) ; } // ------------------------------------------------------------------------- add_action( 'admin_menu' , 'add_this_plugin_to_the wordpress_admin_menu' ) ; // -------------------------------------------------------------------------

But if your plugins make extensive use of WordPress roles and capabilities – or if your demoing multiple plugins, each targeted at users with different roles/capabilities – you may want to be more picky about the $capability you assign to the demo versions of your plugins.

Questions?   Problems?   Clarification?   Help?

If you have any questions or need any clarification about adding your plugins to the demo back-end, please don’t hesitate to contact us on our Contact Form.

We monitor submissions regularly.  And should respond to most queries well within 24 hours.

Leave a Reply

Your email address will not be published. Required fields are marked *