Support » Plugin: Remove Dashboard Access » How to hide more then 1 id inside the toolbar

  • Resolved r1nk

    (@r1nk)


    Hello, based on this code what if I want to hide ‘SOMETHING’ and ‘SOMEWHERE’ ?

    /**
    * Filter hidden Toolbar menus on the front-end.
    *
    * @param array $ids Toolbar menu IDs.
    * @return array (maybe) filtered front-end Toolbar menu IDs.
    */
    function wpdocs_hide_some_toolbar_menu( $ids ) {
    $ids[] = ‘SOMETHING’;
    return $ids;
    }
    add_filter( ‘rda_frontend_toolbar_nodes’, ‘wpdocs_hide_some_toolbar_menu’ );

Viewing 1 replies (of 1 total)
  • Plugin Author Drew Jaynes

    (@drewapicture)

    You would just add both of them to the array. Something like:

    
    function wpdocs_hide_some_toolbar_menu( $ids ) {
    	$ids[] = 'SOMETHING';
    	$ids[] = 'SOMEWHERE';
    
    	return $ids;
    }
    add_filter( ‘rda_frontend_toolbar_nodes’, ‘wpdocs_hide_some_toolbar_menu’ );
    

    Or if you anticipated wanting to add even more items later, doing it with an array_merge() is a bit cleaner and easier to mantain:

    
    function wpdocs_hide_some_toolbar_menu( $ids ) {
    	$new_ids = array( 'SOMETHING', 'SOMEWHERE' );
    	$ids = array_merge( $ids, $new_ids );
    
    	return $ids;
    }
    add_filter( ‘rda_frontend_toolbar_nodes’, ‘wpdocs_hide_some_toolbar_menu’ );
    
Viewing 1 replies (of 1 total)
  • The topic ‘How to hide more then 1 id inside the toolbar’ is closed to new replies.