Suppose you want to create a Menu and don’t want to show it to Admin. Admin or Administrator is the first user of your Drupal website and it has all the access. Normally the user id (uid) of admin is 1. So, you can hide a menu from admin using the “access callback” in “menu_hook“. Lets say our module name is “test”.
<?php /*** Implementation of hook_menu(). */ function test_menu() { $items = array(); $items['earnings'] = array( 'title' => t('Earnings'), 'page callback' => 'earnings', 'access callback' => 'check_user', ); return $items; } function check_user() { global $user; if ($user->uid == 1) { return FALSE; } return TRUE; } ?>
Here we have used an “access callback” function “check_user()” for menu “earnings”. In “check_user()” function we have checked the uid of currently logged in user. If the currently logged in user is admin (uid = 1) then we return FALSE otherwise we returned TRUE.