function user_is_logged_in

You are here

7 user.module user_is_logged_in()
6 user.module user_is_logged_in()

Determines if the current user is logged in.

Return value

bool TRUE if the user is logged in, FALSE if the user is anonymous.

2 calls to user_is_logged_in()
user_menu_site_status_alter in modules/user/user.module
Implements hook_menu_site_status_alter().
user_menu_title in modules/user/user.module
Menu item title callback for the 'user' path.
4 string references to 'user_is_logged_in'
drupal-6.bare.database.php in modules/simpletest/tests/upgrade/drupal-6.bare.database.php
Bare installation of Drupal 6.17, for test purposes.
drupal-6.filled.database.php in modules/simpletest/tests/upgrade/drupal-6.filled.database.php
Filled installation of Drupal 6.17, for test purposes.
session_test_menu in modules/simpletest/tests/session_test.module
Implements hook_menu().
user_menu in modules/user/user.module
Implements hook_menu().

File

modules/user/user.module, line 1545
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

In the example above, the access callback should be specified as

<?php
 
// ...
 
'access callback' => 'user_is_logged_in',
?>

See hook_menu() for more details.