Admin Bar Items – set visibility for front-end and backend

Hello,

the ‘Ultimate Branding’ plugin and its module ‘Custom Admin Bar’ allows to add custom menu items to admin bar. Is there a way to setup a different visibility for the items, so I can set some items to be displayed only in the front-end and other in the backend?

Example:

‘Dashboard’ menu item – should be visible only in the front-end

‘Visite Website’ menu item – visible only in the backend

Best regards,

Damian

  • time4novelty
    • The Incredible Code Injector

    Ok, I figured it out :slight_smile: I can remove the items and set a rule, what to remove only from front-end and what from backend:

    function remove_frontback( $wp_admin_bar ) {
    if ( !is_admin() ) { // front-end
    $wp_admin_bar->remove_node( 'ub_admin_bar_xxxx' ); // replace xxxx with menu item number
    }
    else { // backend
    $wp_admin_bar->remove_node( 'ub_admin_bar_xxxx' ); // replace xxxx with menu item number
    }
    }

    Best regards,

    Damian

  • time4novelty
    • The Incredible Code Injector

    I forgot to hook the function in above example, below the full code:

    function remove_frontback( $wp_admin_bar ) {
    if ( !is_admin() ) { //front-end
    $wp_admin_bar->remove_node( 'ub_admin_bar_xxxx' ); //replace xxxx with menu item number
    }
    else { //backend
    $wp_admin_bar->remove_node( 'ub_admin_bar_xxxx' ); //replace xxxx with menu item number
    }
    }
    add_action( 'admin_bar_menu', 'remove_frontback', 999 );

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.