English 中文(简体)
How to create a custom front page redirect for anonymous user?
原标题:

I have a web site at what-i.com that uses Drupal Commons profile. I have created a custom theme called whati and placed it in /sites/all/themes folder. My page-front.tpl.php is supposed to drive my front page.

It has an if-else statements for 2 scenarios: logged in and non-logged in users. For logged in users, everything works great: upon logging in, the user sees my custom front page. For non logged (anonymous) users, it always forwards them to http://what-i.com/user?destination=home. I don t know how to override that redirect: it does not pick up on the if statement in my page-front.tpl.php, I tried using frontpage module with no success, and I also tried to change the front page settings under Site Information to no avail.

Can anybody help me to resolve this issue: that is, instead of being redirected to user?destination=home, I want my anonymous users to see a custom front page I created.

问题回答

You can do this from a TPL file or a module init().

From a x.tpl.php:

if (drupal_is_frontpage()) {
   global $user;
   if ($user->uid == 0) {
       drupal_goto( some page );
   }
 }

From a module:

mymodule_init() {
   global $user;
   if ($user->uid == 0 && drupal_is_frontpage()) {
      drupal_goto( some page );
   }
}




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签