Skip to:
Content
Pages
Categories
Search
Top
Bottom

Changing adminbar site-name url


  • Georgio
    Participant

    @georgio-1

    Hi everybody,

    When you are in the dashboard and click on the site name (in the left corner of the adminbar) you are normally redirected to the site url (homepage), which in my case is pretitude.com

    How can change that url, so that the user goes to another page, for example pretitude.com/activity/ ?

    Why I want to do that:

    Because my homepage is the register page. This page normally can’t be seen by a logged in user, but it is cached by the browser and users see it and think they are logged out (while they are not).

    Any idea?

    Here is a screenshot

Viewing 7 replies - 1 through 7 (of 7 total)

  • mrjarbenne
    Participant

    @mrjarbenne

    You could customize the adminbar completely, using this snippet. I’m hiding the W menu, but you could probably hid the Sites menu and then add your own dropdown with the requisite links.

    http://www.wpbeginner.com/plugins/how-to-add-edit-re-order-or-hide-wordpress-admin-menus/

             /**
    	 * Adds custom "Home" menu to WP Adminbar.
    	 *
    	 * Also removes the "WP logo" menu.
    	 *
    	 * @param object $wp_admin_bar The WP Admin Bar object
    	 */
    	public function add_custom_parent_menu( $wp_admin_bar ) {
    
    		/**
    		 * Removing the "W" menu
    		 */
    		$wp_admin_bar->remove_menu( 'wp-logo' );
    
    		/**
    		 * Create a "Home" menu.
    		 *
    		 * First, just create the parent menu item.
    		 */
    		$wp_admin_bar->add_menu( array(
    			'id' => 'commonlinks',
    			'parent' => '0', //puts it on the left-hand side
    			'title' => 'Home',
    			'href' => ('INSERT LINK HERE')
    		) );
    
    		/**
    		 * Add submenu items to "Home" menu.
    		 */
    		// Only show the following for logged-in users
    		if ( current_user_can( 'read' ) ) {
    			// Support link
    			$wp_admin_bar->add_menu( array(
    				'id' => 'support',
    				'parent' => 'commonlinks',
    				'title' => 'Support',
    				'href' => ('INSERT LINK HERE')
    			) );
    
    			// Blog request form
    			$wp_admin_bar->add_menu( array(
    				'id' => 'blogrequest',
    				'parent' => 'commonlinks',
    				'title' => 'Stuff',
    				'href' => ('INSERT LINK HERE' )
    			) );
    
    			// Developers blog
    			$wp_admin_bar->add_menu( array(
    				'id' => 'developments',
    				'parent' => 'commonlinks',
    				'title' => 'Developments',
    				'href' => ('INSERT LINK HERE' )
    			) );
    
    		}
    
    	}

    Georgio
    Participant

    @georgio-1

    Thanks @mrjarbenne for your response.

    Unfortunately your code doesn’t work for me; it makes my dashboard a blank page. I already tested the concept “remove the original Home in order to add my own customized Home” with snippets I found on the internet, but this solution is not compatible with responsiveness. All the links you add on the adminbar, will disappear when you see the site on a small screen, for example on a smartphone.

    So the problem remains and I think the only solution is to change the URL of the original Home


    mrjarbenne
    Participant

    @mrjarbenne

    Apologies. This is better. Missed a few steps:

    //Customize Adminbar
    
    add_action('admin_bar_menu', 'customize_admin_bar', 11 );
    function customize_admin_bar( $wp_admin_bar ) {
     
    //Remove the "W" menu
    
    $wp_admin_bar->remove_menu( 'wp-logo' );
    
    /**
    * Create a "Home" menu.
    *
    * First, just create the parent menu item.
    */
    		$wp_admin_bar->add_menu( array(
    			'id' => 'commonlinks',
    			'parent' => '0', //puts it on the left-hand side
    			'title' => 'Home',
    			'href' => ('INSERT LINK HERE')
    		) );
    
    		/**
    		 * Add submenu items to "Home" menu.
    		 */
    		// Only show the following for logged-in users
    		if ( current_user_can( 'read' ) ) {
    			// Support link
    			$wp_admin_bar->add_menu( array(
    				'id' => 'support',
    				'parent' => 'commonlinks',
    				'title' => 'Support',
    				'href' => ('INSERT LINK HERE')
    			) );
    
    			// Blog request form
    			$wp_admin_bar->add_menu( array(
    				'id' => 'blogrequest',
    				'parent' => 'commonlinks',
    				'title' => 'Stuff',
    				'href' => ('INSERT LINK HERE' )
    			) );
    
    			// Developers blog
    			$wp_admin_bar->add_menu( array(
    				'id' => 'developments',
    				'parent' => 'commonlinks',
    				'title' => 'Developments',
    				'href' => ('INSERT LINK HERE' )
    			) );
    
    		}
    
    	}

    In order to force that menu to appear on mobile, you need to tweak the CSS with something like this:

    #wpadminbar li#wp-admin-bar-commonlinks {
    	display: block;
    }

    Georgio
    Participant

    @georgio-1

    The new code adds indeed a Home. Screenshot

    But this Home still doesn’t show on smaller screns. Screenshot

    I have added the css, but it has no effect. As I see only icons are shown on small screens. Unfortunately…


    Georgio
    Participant

    @georgio-1

    Finally I could resolve the problem after reading this article

    This developer suggests creating a plugin. The result is a link with a dashicon but it is not responsive. To make it responsive (show on mobile), I added in the css file of the plugin a snippet I fould elsewhere:

    @media screen and (max-width: 782px) {
    		  #wpadminbar li#wp-admin-bar-XXX {
    					display: block;
    		  }
    }

    Replace XXX with your id


    mrjarbenne
    Participant

    @mrjarbenne

    You could completely customize the Admin-bar. This snippet should help, put in either the functions.php file of your theme, or in the bp-custom.php file. It should give you a good idea of what is possible. I’m hiding the W menu. You could probably hide the Site dropdown altogether and then craft your own dropdown with links to different items. Particularly if this is a single install of BP, and not a Network/Multisite install, there really isn’t any reason for your users to see the Site dropdown:

    	/**
    	 * Adds custom "Home" menu to WP Adminbar.
    	 *
    	 * Also removes the "WP logo" menu.
    	 *
    	 * @param object $wp_admin_bar The WP Admin Bar object
    	 */
    	public function add_custom_parent_menu( $wp_admin_bar ) {
    
    		/**
    		 * Removing the "W" menu
    		 */
    		$wp_admin_bar->remove_menu( 'wp-logo' );
    
    		/**
    		 * Create a "Home" menu.
    		 *
    		 * First, just create the parent menu item.
    		 */
    		$wp_admin_bar->add_menu( array(
    			'id' => 'commonlinks',
    			'parent' => '0', //puts it on the left-hand side
    			'title' => 'Home',
    			'href' => ('http://domain.com/activity')
    		) );
    
    		/**
    		 * Add submenu items to "Home" menu.
    		 */
    		// Only show the following for logged-in users
    		if ( current_user_can( 'read' ) ) {
    			// Support link
    			$wp_admin_bar->add_menu( array(
    				'id' => 'support',
    				'parent' => 'commonlinks',
    				'title' => 'Support',
    				'href' => ('http://domain.com/support')
    			) );
    
    			// Blog request form
    			$wp_admin_bar->add_menu( array(
    				'id' => 'blogrequest',
    				'parent' => 'commonlinks',
    				'title' => 'Feedback',
    				'href' => ('http://domain.com/feedback' )
    			) );
    
    			// Developers blog
    			$wp_admin_bar->add_menu( array(
    				'id' => 'developments',
    				'parent' => 'commonlinks',
    				'title' => 'Developments',
    				'href' => ('http://domain.com/developments' )
    			) );
    
    		}
    
    	}

    Georgio
    Participant

    @georgio-1

    Sorry, after resolving the problem as I mentionned above, I completely forgot this thread.
    Thank you very much for your code. I saved it in case it is useful in the future.
    Have a nice day!

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Skip to toolbar