1

i'm building membership website, and i want to build pages only for users that logged in. What i'm writing in the access callback to give access only to logged in users?

'access callback' => '?'

Thank you.

Joseph Quinsey
  • 9,553
  • 10
  • 54
  • 77
Valoda
  • 335
  • 1
  • 5
  • 21
  • 1
    Maye this thread will help you get started http://stackoverflow.com/questions/3035132/what-is-the-opposite-of-access-callback-user-is-anonymous – Neograph734 Nov 22 '12 at 09:31
  • I'm trying your code, and still unregistered users can this the page, any other solution? – Valoda Nov 25 '12 at 10:27

2 Answers2

3

You can use the user_is_logged_in() function to check if a user is logged in. Like this:

$items['custmomenu'] => array(
  'title' => 'yourtitle',
  'page callback' => 'yourcallback function',
  'access callback' => 'user_is_logged_in',
);
KerrM
  • 5,139
  • 3
  • 35
  • 60
1

You need to use the following access callback as shown below:

$items['mypage'] => array(
  'title' => 'My Page',
  'page callback' => 'mypage_callback',
  'access callback' = > 'user_is_logged_in',
);

More info about checking if a user is logged in:

http://oliverdavies.co.uk/blog/2013/01/09/checking-if-user-logged-drupal-right-way

Chris Novak
  • 579
  • 5
  • 5