• Resolved Nikki Blight

    (@kionae)


    I would like to use the Hide Backend feature on a WordPress Multisite, and for the most part, it’s working as expected. One thing that is a problem however is that the links to other sites in the network the in the admin bar in the WordPress backend don’t change to accommodate the custom backend login url.

    All of the sites in my multisite have their own domain. So, for example, if I attempt to switch from mysite.com to myothersite.com via the admin bar, the link points to myothersite.com/wp-admin instead of myothersite.com/custom-login. If I’m not already logged into the site I’m switching to, I get kicked to a 404 not found page rather than the login screen. Is there a way to accommodate this on multisites that are using separate domains?

Viewing 1 replies (of 1 total)
  • Thread Starter Nikki Blight

    (@kionae)

    I ultimately couldn’t figure out a way to do this without modifying core files, and ended up just adding a new menu to the admin bar. It’s kind of hacky, since I have to remember to use THAT menu instead of the ones built into wordpress when switching from one site to another, but it works, at least.

    //Add a custom menu to accomodate the hidden backend login page
    function customize_admin_bar( $wp_admin_bar ) {
    	//we'll need to know the hide-backend slug from ithemes security, and whether or not it's even enabled
    	$options = get_network_option(null, 'itsec-storage');
    
    	//only show this menu for admin users
    	if ( current_user_can('administrator') && $options['hide-backend']['enabled']) {
    		
    		$sites = get_sites(); //get a list of all the sites in the network		
    		
    		//First, just create the parent menu item.
    		$wp_admin_bar->add_menu( array(
    			'id' => 'customnetworklinks',
    			'parent' => '0', //puts it on the left-hand side
    			'title' => '<span class="ab-icon dashicons dashicons-admin-network"></span> Network Login',
    			'href' => ('INSERT LINK HERE')
    		) );
    		
    		//next, add the submenus
    		foreach($sites as $site) {
    			$url = $site->domain.$site->path.$options['hide-backend']['slug'];
    			$details = get_blog_details($site->blog_id);
    			
    			//add a special entry for the network admin dashboard
    			if($site->blog_id == 1) {
    				$wp_admin_bar->add_menu( array(
    					'id' => 'site'.$site->site_id.'network',
    					'parent' => 'customnetworklinks',
    					'title' => 'Network Admin Dashboard',
    					'href' => $site->domain.$site->path.$options['hide-backend']['slug'].'/network'
    				) );
    			}
    			
    			$wp_admin_bar->add_menu( array(
    				'id' => 'site'.$site->id,
    				'parent' => 'customnetworklinks',
    				'title' => $details->blogname,
    				'href' => $url
    			) );
    		}
    	}
    }
    add_action('admin_bar_menu', 'customize_admin_bar', 11 );
Viewing 1 replies (of 1 total)
  • The topic ‘Hide Backend – change admin url in admin bar menu’ is closed to new replies.