• Resolved actionTurtle

    (@actionturtle)


    Hello,

    I just noticed some very cool code in the wp-admin/network/settings.php

    * Filter available network-wide administration menu options.
    			 *
    			 * Options returned to this filter are output as individual checkboxes that, when selected,
    			 * enable site administrator access to the specified administration menu in certain contexts.
    			 *
    			 * Adding options for specific menus here hinges on the appropriate checks and capabilities
    			 * being in place in the site dashboard on the other side. For instance, when the single
    			 * default option, 'plugins' is enabled, site administrators are granted access to the Plugins
    			 * screen in their individual sites' dashboards.
    			 *
    			 * @since MU
    			 *
    			 * @param array $admin_menus The menu items available.
    			 */
    			$menu_items = apply_filters( 'mu_menu_items', array( 'plugins' => __( 'Plugins' ) ) );
    			$fieldset_end = '';
    			if ( count( (array) $menu_items ) > 1 ) {
    				echo '<fieldset><legend class="screen-reader-text">' . __( 'Enable menus' ) . '</legend>';
    				$fieldset_end = '</fieldset>';
    			}
    			foreach ( (array) $menu_items as $key => $val ) {
    				echo "<label><input type='checkbox' name='menu_items[" . $key . "]' value='1'" . ( isset( $menu_perms[$key] ) ? checked( $menu_perms[$key], '1', false ) : '' ) . " /> " . esc_html( $val ) . "</label><br/>";
    			}
    			echo $fieldset_end;
    			?>

    So this gives me a check box on my network admin settings to allow individual site admins the ability to see the plugins page or not. Very Very cool because its just returns a blank page that says “You do not have sufficient permissions to access this page.”

    How could i duplicate the filters so I could also have checkboxes for “themes, settings, users and tools”? So if an admin tries to go to those pages they get the “You do not have sufficient permissions to access this page.”

    What would also be the best way to do this so WP updates still work? Like I am pretty sure I could go in and duplicate the filters to the settings.php page and that would work but next time I go to update WP i would have to remember to level the settings.php page… And having to add the functions to each sites child theme does not seem like the best answer either…

    Thanks so much!!! Really looking to see whats possible ??

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Limit site admin privileges…’ is closed to new replies.