Community Documentation

front_page Snippet: Redirecting logged in users to a specific page, such as their profile or blog.

Last updated October 6, 2006. Created by Dublin Drupaller on April 2, 2006.
Edited by pwolanin. Log in to edit this page.

PLEASE NOTE! The following snippet is user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**
* This php snippet when used in a front_page.module text area for
* authenticated users will redirect users to a specific page on login
*
* Change the values for page and the link to suit
*
* Tested and works with drupal 4.6, 4.5 and 4.7.
*/
global $user;
$output = 'user/($user->id)';
drupal_goto($path = $output, $query = NULL, $fragment = NULL);
?>

Notes: to automatically redirect the logged in user to their own blog, change the 2nd line

from this:

$output = 'user/($user->id)';

to this

$output = 'blog/($user->id)';

Hope that's of use to others

Dub

About this page

Drupal version
Drupal 4.5.x or older, Drupal 4.6.x, Drupal 4.7.x

Reference

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here