Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to remove the export.php page from WordPress admin menu -> tools for a multisite so only the network admin could see it

I have the following code so far but can't get it to work.

//***************************************************
// Remove export Page
//***************************************************
function remove_menu_export_pages() {
    remove_menu_page('export.php'); 
}
add_action( 'admin_init', 'remove_menu_export_pages' );

How can I solve this?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Whenever in doubt about a WordPress function, consult the Codex: Function_Reference/remove_menu_page.

The correct function is remove_submenu_page hooked into admin_menu.

add_action( 'admin_menu', 'remove_submenu_wpse_82873' );

function remove_submenu_wpse_82873() 
{
    global $current_user;
    get_currentuserinfo();

    // If user not Super Admin remove export page
    if ( !is_super_admin() ) 
    {
        remove_submenu_page( 'tools.php', 'export.php' );
    }
}

And then you'd probably would like to also block the direct access to that page through the URL address (http://example.com/wp-admin/export.php):

add_action( 'admin_head-export.php', 'prevent_url_access_wpse_82873' );

function prevent_url_access_wpse_82873()
{
    global $current_user;

    // Only Super Admin Authorized, exit if user not
    if ( !is_super_admin() ) {

      // User not authorized to access page, redirect to dashboard
      wp_redirect( admin_url( 'index.php' ) ); 
      exit;
    }
}
share|improve this answer
    
I tried it works great however the export page is not available to supper admin –  Oudin Jan 24 '13 at 18:03
    
@Oudin, is it working with your edit? –  brasofilo Jan 24 '13 at 19:07
    
yes it does tested it works –  Oudin Jan 25 '13 at 0:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.