Forum
How to Define {returnURL} for Members Password Reset?
In Perch Settings/Members/Login page path, the value is something like > /members/login.php?r={returnURL}
How do I define > {returnURL}?
I'm looking at redirecting members to a specific page after login from the "login" link in password reset email. Reset can happen at different sections of the site, so will be good to define returnURL.
Tried setting $returnURL in reset.php that calls perch_member_form('reset_password.html') but it doesn't work. Tried specifying value of 'r' in login_form.html template and it doesn't work.
reset.php:
<?php include($_SERVER['DOCUMENT_ROOT'].'/perch/runtime.php');
perch_layout('sub.header');
perch_layout('global.nav');
if((perch_get('r'))) {
$returnURL = perch_get('r');
PerchSystem::set_var('returnURL', $returnURL);
}
perch_member_form('reset_password.html');
?>
</div>
<?php
PerchUtil::output_debug();
perch_get_javascript();
perch_layout('global.footer');
?>
Here's my login_form.html template:
<perch:form id="login" method="post" app="perch_members">
<fieldset>
<legend>Log in</legend>
<perch:error for="all" type="login">
<p class="error">Those details do not match our records.</p>
</perch:error>
<div>
<perch:label for="email">Email</perch:label>
<perch:input type="email" id="email" required="true" label="Email" />
<perch:error for="email" type="required">Required</perch:error>
<perch:error for="email" type="format">Check format of address</perch:error>
</div>
<div>
<perch:label for="password">Password</perch:label>
<perch:input type="password" id="password" required="true" label="Password" />
<perch:error for="password" type="required">Required</perch:error>
</div>
<div>
<perch:input type="submit" id="submit" value="Log in" />
<perch:input type="hidden" id="r" value="<perch:members id="perch_page_path" />" />
<p><a href="/members/reset?r=<perch:members id="perch_page_path" />">Forgot password</a></p>
</div>
</fieldset>
</perch:form>
Hi,
I'm not sure if I've understood the requirement correctly, but do you get the desired affect if you add and action with
<perch:forms id="returnURL" />
to your opening form tag? eg.Thanks for the response! Sorry let me explain better.
For members who requested for password reset, this is the intended outcome:
On any page that displays more info specific to members, click on 'Forgot password' link
Receive email with new password
Click on 'log back in' link in email (which is currently
/members/login/?r=
)Login and get redirected to 'r' value
Problem is current 'r' value is blank. I presume it's taken from member settings page login path:
/members/login.php?r={returnURL}
Snippet from email template emails/reset_password.html:
The
{returnURL}
gets automatically replaced with the path of the current page. The idea begin it can bounce you to the login page and then back to where you started.Exactly what I need! Except that it's currently blank in the login URL
/members/login.php?r=
Reset is currently called from reset.php. So it should at least carry value of
reset.php
, did I get it right?How can I make it work?
It shouldn't be blank. Can you show us what you're doing?
Sure (Thanks for the response!). There are 2 sections for members to access -
/clubttm
and/merchandise
(for checkout purposes). - At merchandise checkout, members not logged in should be prompted to login with option to reset password if they forgot login details. - After receiving email with new password, members can click on login link to do so, and be redirected to/merchandise/checkout
to finish the checkout process. - The above step should apply to login tasks for accessing/clubttm
area as wellHere's my
/merchandise/checkout.php
:Here's my template
login_form.html
:<perch:showall />
for the above template at/merchandise/checkout
:Here's my
/clubttm/reset.php
:Here's my template
reset_password.html
:<perch:showall />
for the above template at/clubttm/reset
:Debug after submit Reset:
Login URL from reset password email:
https://ttmda-perch.macky/clubttm/login?r=