If you have a Drupal 6 site, and need to secure a page so only users logged in can see it, do the following…
if(user_is_logged_in() != TRUE){ // Do stuff, i.e. // header('Location: /'); // exit('You do not have permission to view this page, please log in with the correct access.'); }
This makes use of the Drupal 6 function user_is_logged_in()
This can also be used in the page.tpl with a page title, (which uses the $title variable)…
if($title == 'Secured Page' && user_is_logged_in() == TRUE){ // Do stuff that will only show if the page title is Secured Page and the user is logged in. }
This can also be used to specify just the administrator, using the $is_admin variable…
if($is_admin != TRUE) { // Redirect or exit // header('Location: /'); // exit('You do not have permission to view this page, please log in with the correct access.'); }
Main Category