Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to make the admin bar transparent?

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

  • @mcuk
    Participant

    @mcuk

    Adding this to your style.css in child theme should work:

    #wpadminbar { 
        background: transparent; 
    }

    Georgio
    Participant

    @georgio-1

    It works fine! Thank you very much!


    @mcuk
    Participant

    @mcuk

    🙂


    Georgio
    Participant

    @georgio-1

    With your code and the use of the plugin Better Admin Bar I have made a nice unobtrusive admin bar.
    Any idea how to hide/remove the dashboard link for NON-admins? Thanks.

    screenshot


    @mcuk
    Participant

    @mcuk

    You can remove access to the WP admin bar by non admins using this in your functions.php file:

    function restrict_dashboard_access() {
    	if ( is_admin() && ! current_user_can( 'administrator' ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
    		wp_redirect( home_url() );
    	exit;
    	}
    }
    add_action( 'init', 'restrict_dashboard_access' );

    @mcuk
    Participant

    @mcuk

    Also to remove the bar itself for non admins put this in your functions.php :

    function remove_admin_bar() {
    	if ( !current_user_can( 'administrator' ) && !is_super_admin() ) {
    	  show_admin_bar(false);
    	}
    }
    add_action( 'after_setup_theme', 'remove_admin_bar' );

    Georgio
    Participant

    @georgio-1

    Sorry, I didn’t explain it well: I want to keep the admin bar for non-admins (it is usefull for the notifications etc) but make disappear the word “Pretitude” (that gives access to dashboard).
    Well, after using your code, non-admins don’t have access to dashboard any more, but the word Pretitude stays visible and points to the home page. This word been now useless, I want to hide it for esthetical reasons, because it is near the logo and the whole thing is ungly. Is that possible?

    Thanks again for the code!


    @mcuk
    Participant

    @mcuk

    Yeah it’s possible 🙂 (assuming that the bit you are talking about is the one im thinking of haha).

    Two methods:

    1. CSS

    li#wp-admin-bar-site-name {
        display: none;
    }

    2. Add this to functions.php file

    function remove_site_name( $wp_admin_bar ) {
    	$wp_admin_bar->remove_node( 'site-name' );
    }
    add_action( 'admin_bar_menu', 'remove_site_name', 999 );

    Both will hide the word for both ALL users including admins (I prefer the second but its up to you).

    If you want to leave the word Pretitude there for admins only to access the dashboard then adding an if statement into the function (similar to the one in the remove_admin_bar() function) should work.

    Hope it works!


    Georgio
    Participant

    @georgio-1

    Wow, it works like a charm! Thank you very much and have a nice day!


    @mcuk
    Participant

    @mcuk

    You too 🙂

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