Index: trunk/wb/account/login_form.php
===================================================================
--- trunk/wb/account/login_form.php	(revision 42)
+++ trunk/wb/account/login_form.php	(revision 43)
@@ -71,6 +71,7 @@
 <form name="login" action="<?php echo WB_URL.'/account/login'.PAGE_EXTENSION; ?>" method="post">
 <input type="hidden" name="username_fieldname" value="<?php echo $username_fieldname; ?>" />
 <input type="hidden" name="password_fieldname" value="<?php echo $password_fieldname; ?>" />
+<input type="hidden" name="redirect" value="<?php echo $thisApp->redirect_url;?>" />
 
 <table cellpadding="5" cellspacing="0" border="0" width="90%">
 <tr>
Index: trunk/wb/account/login.php
===================================================================
--- trunk/wb/account/login.php	(revision 42)
+++ trunk/wb/account/login.php	(revision 43)
@@ -62,7 +62,7 @@
 									"MIN_PASSWORD_LEN" => "2",
 									"MAX_USERNAME_LEN" => "30",
 									"MAX_PASSWORD_LEN" => "30",
-									"LOGIN_URL" => WB_URL."/account/login".PAGE_EXTENSION,
+									"LOGIN_URL" => WB_URL."/account/login".PAGE_EXTENSION.'?redirect='.$_REQUEST['redirect'],
 									"DEFAULT_URL" => WB_URL.PAGES_DIRECTORY."/index".PAGE_EXTENSION,
 									"TEMPLATE_DIR" => ADMIN_PATH."/login",
 									"TEMPLATE_FILE" => "template.html",
@@ -69,7 +69,8 @@
 									"FRONTEND" => true,
 									"FORGOTTEN_DETAILS_APP" => WB_URL."/account/forgot.php".PAGE_EXTENSION,
 									"USERS_TABLE" => TABLE_PREFIX."users",
-									"GROUPS_TABLE" => TABLE_PREFIX."groups"
+									"GROUPS_TABLE" => TABLE_PREFIX."groups",
+									"REDIRECT_URL" => $_REQUEST['redirect']
 							)
 					);
 
Index: trunk/wb/framework/class.login.php
===================================================================
--- trunk/wb/framework/class.login.php	(revision 42)
+++ trunk/wb/framework/class.login.php	(revision 43)
@@ -61,6 +61,7 @@
 		$this->forgotten_details_app = $config_array['FORGOTTEN_DETAILS_APP'];
 		$this->max_username_len = $config_array['MAX_USERNAME_LEN'];
 		$this->max_password_len = $config_array['MAX_PASSWORD_LEN'];
+		$this->redirect_url = $config_array['REDIRECT_URL'];
 		// Get the supplied username and password
 		if ($this->get_post('username_fieldname') != ''){
 			$username_fieldname = $this->get_post('username_fieldname');
@@ -84,10 +85,12 @@
 		}
 		// If the url is blank, set it to the default url
 		$this->url = $this->get_post('url');
+		if ($this->redirect_url!='') {
+			$this->url = $this->redirect_url;
+		}		
 		if(strlen($this->url) < 2) {
 			$this->url = $config_array['DEFAULT_URL'];
 		}
-		// Login the user
 		if($this->is_authenticated() == true) {
 			// User already logged-in, so redirect to default url
 			header('Location: '.$this->url);
@@ -134,6 +137,7 @@
 			$this->password = md5($this->password);
 			if($this->authenticate()) {
 				// Authentication successful
+				//echo $this->url;exit();
 				header("Location: ".$this->url);
 			} else {
 				$this->message = $MESSAGE['LOGIN']['AUTHENTICATION_FAILED'];
Index: trunk/wb/framework/class.frontend.php
===================================================================
--- trunk/wb/framework/class.frontend.php	(revision 42)
+++ trunk/wb/framework/class.frontend.php	(revision 43)
@@ -220,7 +220,7 @@
 			// Check if the user is authenticated
 			if($this->is_authenticated() == false) {
 				// User needs to login first
-				header("Location: ".WB_URL."/account/login".PAGE_EXTENSION);
+				header("Location: ".WB_URL."/account/login".PAGE_EXTENSION.'?redirect='.$this->link);
 			}
 			// Check if we should show this page
 			if($this->show_page($this->page) == false) {
