2

So I want to provide similar redirection logic as we have on drupal.org and redirection to dashboard to logged in users but also allow access to the /front page. I can't seem to get it to redirect ONLY on front page. Here is the current code I have:

function MYMODULE_init(){
  global $user;
  if(drupal_is_front_page() && user_access('view own dashboard')){
    drupal_goto('user/'.$user->uid.'/dashboard');
  }
}

It is also redirecting the page itself to the dashboard still and not simply the <root>

1

I think you should be using hook_user_login instead of hook_init.

  • Yes, I have other code that handles the initial login redirection. That's not an issue. What I mean is that I need a front page redirect from just the root; not the page itself. – markwk Oct 4 '12 at 19:40
  • can you please define root ?? by giving path example like www.example.com is frontpage www.example.com/dashoard is the dashboard. – junedkazi Oct 4 '12 at 19:52
  • So if you set the front page to /frontpage then www.example.com and www.example.com equal "front" and get redirected. I define root as www.example.com. drupal_is_front_page seems to not distinguish between front as root and page that is defined as frontpage. – markwk Oct 5 '12 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.