How can I hide tabs for users not logged in?
Hide viewsource tab for users without edit permission (usually unregistered users if you've set it so): $wgHVTFUUviewsToRemove = array( 'viewsource' );
Hi Tim,
i want to hide "View Source" Tab for Anonymous users. In the LocalSettings.php If i set $wgGroupPermissions['*']['edit'] = false; then its hides the Edit Tab, Where as if i set $wgHVTFUUviewsToRemove = array( 'viewsource' ); its still shows the "View soruce" tab. So could you please help me. Thanks in advance.
Thanks, Mohan
If you are not loggedin, you shouldn't be able to see viewsource tab (and no edit tab because edit tab gets into viewsource tab if you have no permission to edit pages). Do you use my code from above? You can try to purge the cache with ?action=purge
Hi Tim,
i am not logged in but still it shows the "View source" tab. Can you tell me which code & in which file i have to update your code? bcoz my mediawiki version is -1.18.3. The tell me how to try Purge option (under in which file). Rgds, Mohan
Create folder HideVariousTabsFromUnauthorizedUsers in extensions directory, create HideVariousTabsFromUnauthorizedUsers.php file in HideVariousTabsFromUnauthorizedUsers folder and add the code below to your this file. Then add require_once ( "$IP/extensions/HideVariousTabsFromUnauthorizedUsers/HideVariousTabsFromUnauthorizedUsers.php" ); to your LocalSettings.php. Remove $wgGroupPermissions['*']['edit'] = false; and any other earlier setting of HideVariousTabsFromUnauthorizedUsers extension from LocalSettings.php.
<?php /** * HideVariousTabsFromUnauthorizedUsers * * @package MediaWiki * @subpackage Extensions * * @author: Tim 'SVG' Weyer <t.weyer@ymail.com> * * @copyright Copyright (C) 2012 Tim Weyer * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later * */ $wgExtensionCredits['other'][] = array( 'path' => __FILE__, 'name' => 'HideVariousTabsFromUnauthorizedUsers', 'author' => array( 'Tim Weyer' ), 'url' => 'https://www.mediawiki.org/wiki/User:SVG', 'description' => 'Disables various view tabs (and originally also namespace tabs) from users without <tt>edit</tt> permission for Vector skin', 'version' => '05-28-2012', ); // Hooks $wgHooks['SkinTemplateNavigation'][] = 'fnHVTFUUremoveTabsFromVector'; // Tabs of view to remove $wgHVTFUUviewsToRemove = array( 'viewsource' ); // Remove 'edit' permission from anonymous users $wgGroupPermissions['*']['edit'] = false; /** * @param $sktemplate Title * @param $links * @return bool */ function fnHVTFUUremoveTabsFromVector( SkinTemplate &$sktemplate, array &$links ) { global $wgUser, $wgHVTFUUviewsToRemove; // Only remove tabs if user isn't allowed to edit pages if ( $wgUser->isAllowed( 'edit' ) ) { return false; } // Remove actions tabs foreach ( $wgHVTFUUviewsToRemove as $view ) { if ( $links['views'][$view] ) unset( $links['views'][$view] ); } return true; }
Hi Tim
It seems to work so far for me, THANKS for this extension. I altered this
// Tabs of view to remove
$wgHVTFUUviewsToRemove = array( 'edit', 'history', 'read', 'talk', 'viewsource' );
But it looks like it only works in the main namespace. Tabs of Pages in the MediaWiki or User Namespace still appear. Any ideas ? If possible I would like to hide all Tabs for unlogged users
Hi Tim,
i want to hide "View Source" Tab for Anonymous users. In the LocalSettings.php If i set $wgGroupPermissions['*']['edit'] = false; then its hides the Edit Tab, Where as if i set $wgHVTFUUviewsToRemove = array( 'viewsource' ); its still shows the "View soruce" tab. So could you please help me. Thanks in advance.
Here my requirement is that Anonymous users should not see "Edit & View Source" tabs.
Thanks, Mohan
Duplicate striked by SVG.