18.2.1. How to redirect users to the Login page

If you want your users to be redirected straight to the Login page, rather than the Homepage, do the following:

Right at the begining of the index.php file , add this code after the 'require_once("mainfile.php");' line, like this:

require_once("mainfile.php");
global $user;
if(!is_user($user)) {
  header("Location: modules.php?name=Your_Account");
}

This will send anyone who is not logged in (or registered) to the Your Account (Login) page. See Section 18.6.1 for the inverse procedure - but don't try both. Inline graphic

See how to redirect from forms in a PHP-Nuke block for redirection from other places, like blocks.


Help us make a better PHP-Nuke HOWTO!

Want to contribute to this HOWTO? Have a suggestion or a solution to a problem that was not treated here? Post your comments on my PHP-Nuke Forum!

Chris Karakas, Maintainer PHP-Nuke HOWTO