WordPress.org

Ready to get started?Download WordPress

Forums

mu required Plugins (4 posts)

  1. Slidder
    Member
    Posted 1 year ago #

    OK! I have installed mu and am having a heck of a time getting the required plugins options to not show in users control panels. How do i only have plugins options only appear in the network admins control panel? Now i looked up on the net and i see things about the mu-plugins folder, i tried that but could not get anything to load? What am i either not understanding or missing?

  2. David Sader
    Member
    Posted 1 year ago #

    First - about loading stuff from "mu-plugins".

    "mu-plugins" is a "must use" plugins folder. *php in there will load without the option to activate/deactivate like the usual plugins.

    Further, "mu-plugins" folder does not look inside any folders. mu-plugins will load any *.php files but it will not open a folder unless there is a *.php file telling it too.

    So a bit of trial and error is needed to install a plugin designed for the "plugins" in the "mu-plugins".

    Now let's say I have a plugin folder inside the "mu-plugins" folder named "spam_tools". I'll still need a spam_tools.php file alongside the folder to tell WP to load the contents of the spam_tools folder:

    <?php
      $spam_tools = glob(dirname(__FILE__).'/spam_tools/*.php');
      if( is_array( $spam_tools ) ) {
      	foreach ( $spam_tools as $spam_tool ) {
      		if( is_file( $spam_tool ) )
      			include_once( $spam_tool );
      	}
      }
    ?>

    Second, - restricting plugin menus to the SuperAdmin.

    Since all that will just get a plugin loaded from the "mu-plugins", you'll still need to edit the plugin to keep its menus from appearing to any user but the SuperAdmin. Editing the role/cap is what I would try.

    <?php add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position ); ?>

    The plugin author may add the menu page for users with "manage_options" $capability, it sounds like you want it to be "manage_network_options" instead.

    If you want the menu to only appear in the Network Admin menus, that may need a bit of creativity as well, but it is certainly doable.

  3. Slidder
    Member
    Posted 1 year ago #

    I understand what your saying. Just wasnt expecting this as the last time i used mu it was just plug and play. Why would they change the ease of use? A question i will never pro0bably get answered considering the majority of people who use wordpress are novice.....

    Thanks for your reply and i will work it out.....

  4. David Sader
    Member
    Posted 1 year ago #

    "Why would they change the ease of use?"

    This is not new behaviour. "mu-plugins" has always been this way (8+ years since WPMU?).

    Plug'nplay for *.php yes.

    "mu-plugins" has never read files within folders.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.