function user_is_logged_in

You are here

7 user.module user_is_logged_in()
6 user.module user_is_logged_in()
1 string reference to 'user_is_logged_in'
user_menu in modules/user/user.module
Implementation of hook_menu().

File

modules/user/user.module, line 883
Enables the user registration and login system.

Code

function user_is_logged_in() {
  return (bool) $GLOBALS['user']->uid;
}

Comments

this is good solution when we want check the menu only for users login , can use this in access callback menu property like this

<?php

mymodule_menu

(){
$items=array();
$items['custmomenu'] => array(
     
'title' => 'yourtitle',
     
'page callback' => 'yourcallback function' ,
     
'access callback' = > user_is_logged_in(),
   );
}
?>

the usefull and short solution

That should be:
'access callback' => 'user_is_logged_in',

Otherwise it will become TRUE/FALSE depending on the status of the user when menu cache is refreshed and all other users will (not) get access till the next menu cache refresh.

And don't forget to return $items.