18.2. Modifying the PHP-Nuke Homepage

The PHP-Nuke Homepage is the “Home” module. The Home module is chosen in the modules administration panel. We show:

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.

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

18.2.2. How to restrict the Homepage only to registered users

Suppose that you have set up the News module as the “Homepage module” of your PHP-Nuke, but you want the news articles to be visible only to registered users. Can this be done?

Well, not exactly. Since you want the News module to be visible only to registered users, you cannot have it in the "Home". This means you must put a different module in Home (see hide articles from logged out users). You can do this from the "Put in Home" link in the modules table shown in the modules administration panel (Section 7.1, Figure 7-19).

Once the News module is not in Home anymore, you can edit it and choose that it be visible only by the registered users.

Note

The "Who can View This?" selection box is not available, as long as the module remains the "Home" module of your P HP-Nuke installation. That's why you can't restrict the visibility of the Home module, no matter which module this is. T he reason for this is that it makes little sense to have a Home module and restrict its availability only to registered users, unless you want your site to be generally available only to registered members.