I have a page outside of Drupal (a chat page) that I only want members that are logged into Drupal to be able to access.

Is there a way to do this?

I am using the logged in member's username as their chat ID using the code below which is included in the index.php for the chat app.

chdir('/home/coghlanc/public_html');
set_include_path('/home/coghlanc/public_html'.PATH_SEPARATOR.get_include_path());
 require 'includes/bootstrap.inc';
  drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
global $user;
print_r($user->name);

So, if I am logged in as apple then my chat ID will be apple.

What I would like is to include something on this page that prevents it even being processed/displayed if there is no Drupal name in $user->name.

Thanks,

Comments

cog.rusty’s picture

Can't you simply use

if (!$user->uid) {return;}

or

if ($user->uid) {
  // go on
}
paulcoghlan’s picture

Thanks, I have it working now. I am redirecting users that are not logged in to the login page.

I would still ideally not have the menu option even appear if people aren't logged in but that is another matter.

Thanks for the input;