Index: modules/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user.module,v
retrieving revision 1.548
diff -u -p -r1.548 user.module
--- modules/user.module	6 Jan 2006 07:42:31 -0000	1.548
+++ modules/user.module	7 Jan 2006 08:03:57 -0000
@@ -852,6 +852,7 @@ function user_login($msg = '') {
   }
   $form['pass'] = array('#type' => 'password', '#title' => t('Password'), '#description' => t('Enter the password that accompanies your username.'), '#required' => TRUE, '#attributes' => array('tabindex' => '2'));
   $form['submit'] = array('#type' => 'submit', '#value' => t('Log in'), '#weight' => 2, '#attributes' => array('tabindex' => '3'));
+  $form['destination'] = array('#type' => 'value', '#value' => variable_get('user_post_login_page', 'user'));
   return drupal_get_form('user_login', $form);
 }
 
@@ -888,7 +889,7 @@ function user_login_submit($form_id, $fo
     user_module_invoke('login', $form_values, $user);
 
     // Redirect the user to the page he logged on from.
-    drupal_goto();
+    drupal_goto($form_values['destination'] ? $form_values['destination'] : NULL);
   }
 }
 
@@ -956,7 +957,7 @@ function user_logout() {
   // We have to use $GLOBALS to unset a global variable:
   unset($GLOBALS['user']);
 
-  drupal_goto();
+  drupal_goto(variable_get('user_post_logout_page', '<front>'));
 }
 
 function user_pass() {
@@ -1065,7 +1066,7 @@ function user_register() {
 
   // If we aren't admin but already logged on, go to the user page instead.
   if (!$admin && $user->uid) {
-    drupal_goto('user/'. $user->uid);
+    drupal_goto(variable_get('user_post_registration_page', 'user'));
   }
 
   // Display the registration form.
@@ -1149,7 +1150,7 @@ function user_register_submit($form_id, 
       user_mail($mail, $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
       drupal_set_message(t('Your password and further instructions have been sent to your e-mail address.'));
 
-      drupal_goto();
+      drupal_goto(variable_get('user_post_registration_page', 'user'));
     }
     else {
       // Create new user account, administrator approval required.
@@ -1160,7 +1161,7 @@ function user_register_submit($form_id, 
       user_mail(variable_get('site_mail', ini_get('sendmail_from')), $subject, t("%u has applied for an account.\n\n%uri", array('%u' => $account->name, '%uri' => url("user/$account->uid/edit", NULL, NULL, TRUE))), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
       drupal_set_message(t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />In the meantime, your password and further instructions have been sent to your e-mail address.'));
 
-      drupal_goto();
+      drupal_goto(variable_get('user_post_registration_page', 'user'));
     }
   }
 }
@@ -1770,6 +1771,21 @@ function user_configure() {
   $form['registration'] = array('#type' => 'fieldset', '#title' => t('User registration settings'));
   $form['registration']['user_register'] = array('#type' => 'radios', '#title' => t('Public registrations'), '#default_value' => variable_get('user_register', 1), '#options' => array(t('Only site administrators can create new user accounts.'), t('Visitors can create accounts and no administrator approval is required.'), t('Visitors can create accounts but administrator approval is required.')));
   $form['registration']['user_registration_help'] = array('#type' => 'textarea', '#title' => t('User registration guidelines'), '#default_value' => variable_get('user_registration_help', ''), '#description' => t('This text is displayed at the top of the user registration form.  It\'s useful for helping or instructing your users.'));
+  
+  // User redirection settings.
+  $form['redirection'] = array('#type' => 'fieldset', '#title' => t('User redirection settings'));
+  $form['redirection']['user_post_registration_page'] = array(
+    '#type' => 'textfield', '#title' => t('Post Registration Page'), '#default_value' => variable_get('user_post_registration_page', 'user'),
+    '#description' => t('The page to display after a user registers, such as a welcome page or a terms of use page. If unsure, specify "user" to show the user\'s account page.')
+  );
+  $form['redirection']['user_post_login_page'] = array(
+    '#type' => 'textfield', '#title' => t('Post Login Page'), '#default_value' => variable_get('user_post_login_page', 'user'),
+    '#description' => t('The page to display after a user logs in. If unsure, specify "user" to show the user\'s account page or "&lt;front&gt;" to show the front page. Note that if a user logs in via a block, the user will stay on that page and not be directed to this page.')
+  );
+  $form['redirection']['user_post_logout_page'] = array(
+    '#type' => 'textfield', '#title' => t('Post Logout Page'), '#default_value' => variable_get('user_post_logout_page', '<front>'),
+    '#description' => t('The page to display after a user logs out. If unsure, specify "&lt;front&gt;" to show the front page.')
+  );
 
   // User e-mail settings.
   $form['email'] = array('#type' => 'fieldset', '#title' => t('User email settings'));
