Thread:Project:Support desk/Hidding the toolbox to anonymous users

I have this code to hide the toolbox from anonymous users. But it works after I've logged out, but only on the logout page. If I go to any other page, the toolbox reappears. Can someone help me with this? I am using
 * MW 1.21.1
 * PHP 5.3.24
 * MySQL 5.1.70

// Render portals foreach ( $portals as $name => $content ) { if ( $content === false ) continue; echo "\n\n"; switch( $name ) { case 'SEARCH': break; case 'TOOLBOX': if ( $wgUser->isLoggedIn ) { $this->renderPortal( 'tb', $this->getToolbox, 'toolbox', 'SkinTemplateToolboxEnd' ); }       break; case 'LANGUAGES': if ( $this->data['language_urls'] ) { $this->renderPortal( 'lang', $this->data['language_urls'], 'otherlanguages' ); }       break; default: $this->renderPortal( $name, $content ); break; }       echo "\n\n";