How can I create one button to be actived only on Level Pro on Pro-Sites?

How can I create one button to be actived only on Level Pro on Pro-Sites?

  • Tyler Postle

    Hey Marcos,

    Hope you're doing well today!

    I've been thinking up a solution for this as it's not currently available in the plugin and this is the solution I've got. We add a function that adds a new body class to both pro sites and free sites.

    This way we can create the menu item and add it to Easy Blogging then hide it with some CSS for free sites :slight_smile:

    I've created a small mu-plugin(must use plugin) that will add these body classes and I see you already have the admin CSS module activated in Ultimate Branding, great! We'll need that too.

    1. I've attached the ps-body-class.php mu plugin, unzip the folder and drag that file over to your /wp-content/mu-plugins folder.

    *if the folder doesn't exist then just create it :slight_smile:

    2. Activate the "compatibility mode" add-on in Easy Blogging.

    3. Create your custom menu item ie. Domain Mapping(screenshot attached).

    4. Add this CSS to your Branding > CSS > Admin CSS field:

    .wpmu-free-site li a[href="tools.php?page=domainmapping"] {
    display: none;
    }

    That will hide the Domain Mapping menu item only on free sites.

    If you want to hide a menu item on pro sites then you can use this:

    .wpmu-pro-site li a[href="tools.php?page=domainmapping"] {
    display: none;
    }

    For every new menu item that you want to hide, you can add it to the same style with a comma, for ie.

    .wpmu-free-site li a[href="tools.php?page=domainmapping"], .wpmu-free-site li a[href="edit.php?post_type=product"] {
    display: none;
    }

    and that's it! :slight_smile: now you can hide any menu items you like on either pro or free level sites.

    and I need know if is possible to create sub menus...

    Easy Blogging doesn't currently support sub menus; however, I can add that to the requests list :slight_smile:

    Hope this helps Marcos!

    I'm also just going to post the mu-plugin code here, in-case someone wants to know at a glance what it is:

    <?php
    /**
     *
     * Adds a new body class to both pro level sites and free level sites.
     *
     * Pro level body class = "wpmu-pro-site"
     *
     * Free level body class = "wpmu-free-site"
     *
     */
    
    add_filter( 'admin_body_class', 'ps_body_class' );
    function ps_body_class( $classes ) {
    
            if (function_exists('is_pro_site') && is_pro_site()) {
    
                $classes .= ' wpmu-pro-site';
    
                return $classes;
    
            } else {
    
                $classes .= ' wpmu-free-site';
    
                return $classes;
    
            }
    
    }

    It just checks to see if Pro Sites is active and then if it is it also checks if the site is a pro site - if that returns true it applies the .wpmu-pro-site body class, if it's false then it applies the .wpmu-free-site body class.

    Have a great rest of your day Marcos! If you need any further assistance just let us know.

    All the best,
    Tyler

  • Patrick

    Hi there @fballor

    I hope you are well today!

    The code and steps provided above should still work just fine.

    The tools.php that is referenced in the above code is simply the URL of the Tools admin menu item that the original poster wanted to hide.

    But you can change that to the URL of any admin screen that you wish to hide from not-pro-site users.

    I hope this helps! And thanks for being a member :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.