PDA

View Full Version : How To Change The Redirect For The Login Form


Jake Bunce
Sat 6th May '06, 3:07pm
By default, vBulletin's login forms redirect you back to the page you were viewing. You can define your own redirection URL by adding this hidden field to the login form:


<input type="hidden" name="url" value="REDIRECTION URL HERE" />


The login forms are in two main templates:

Navbar login form

Go to your:

Admin CP -> Styles & Templates -> Style Manager -> « » -> Navigation / Breadcrumb Templates -> navbar

Add the red code. Change the blue redirection URL appropriately:


<!-- login form -->
<form action="login.php" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, $show[nopasswordempty])">
<script type="text/javascript" src="clientscript/vbulletin_md5.js"></script>
<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
<tr>
<td class="smallfont">$vbphrase[username]</td>
<td><input type="text" class="bginput" style="font-size: 11px" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="101" value="$vbphrase[username]" onfocus="if (this.value == '$vbphrase[username]') this.value = '';" /></td>
<td class="smallfont" colspan="2" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="103" id="cb_cookieuser_navbar" accesskey="c" />$vbphrase[remember_me]</label></td>
</tr>
<tr>
<td class="smallfont">$vbphrase[password]</td>
<td><input type="password" class="bginput" style="font-size: 11px" name="vb_login_password" size="10" accesskey="p" tabindex="102" /></td>
<td><input type="submit" class="button" value="$vbphrase[log_in]" tabindex="104" title="$vbphrase[enter_username_to_login_or_register]" accesskey="s" /></td>
</tr>
</table>
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="do" value="login" />
<input type="hidden" name="vb_login_md5password" />
<input type="hidden" name="vb_login_md5password_utf" />
<input type="hidden" name="url" value="REDIRECTION URL HERE" />
</form>
<!-- / login form -->


Standard error login form

Go to your:

Admin CP -> Styles & Templates -> Style Manager -> « » -> STANDARD_ERROR and STANDARD_ERROR_LITE

The field is already there. Just replace $scriptpath with your redirection URL:


<if condition="$show['permission_error']">
<script type="text/javascript" src="clientscript/vbulletin_md5.js"></script>
<form action="login.php" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, $show[nopasswordempty])">
<input type="hidden" name="do" value="login" />
<input type="hidden" name="url" value="$scriptpath" />
<input type="hidden" name="vb_login_md5password" />
<input type="hidden" name="vb_login_md5password_utf" />
$postvars

<input type="hidden" name="s" value="$session[sessionhash]" />

<!-- permission error message - user not logged in -->