1

I'm using the following code but the redirect is not working. After the user registers it takes them back to the home page and not to volunteer/identity. I put a message on the homepage to display if the user is logged in and it appears that they are logged it at that point. This used to work before 2.5 on a different site that I haven't upgraded to 2.5. But now on this new install of 2.5 I can't get it to work.

Has anyone else experienced the same issues?

{% extends "_layout" %}

{% block content %}

<form method="post" accept-charset="UTF-8">
    {{ getCsrfInput() }}
    <input type="hidden" name="action" value="users/saveUser">
    <input type="hidden" name="redirect" value="volunteer/identity">

    {% macro errorList(errors) %}
        {% if errors %}
            <ul class="errors">
                {% for error in errors %}
                    <li>{{ error }}</li>
                {% endfor %}
            </ul>
        {% endif %}
    {% endmacro %}

    {% from _self import errorList %}

    <label for="firstName">First Name</label>
    <input id="firstName" type="text" name="firstName" {% if account is defined %} value="{{ account.firstName }}"{% endif %}>

    {% if entry is defined %}
        {{ errorList(account.getErrors('firstName')) }}
    {% endif %}

    <label for="lastName">Last Name</label>
    <input id="lastName" type="text" name="lastName" required {% if account is defined %} value="{{ account.lastName }}{% endif %}">

    {% if entry is defined %}
        {{ errorList(account.getErrors('lastName')) }}
    {% endif %}

    <label for="email">Email</label>
    <input id="email" type="text" name="email"
        {% if account is defined %} value="{{ account.email }}"{% endif %}>

    {% if account is defined %}
        {{ errorList(account.getErrors('email')) }}
    {% endif %}

    <label for="password">Password</label>
    <input id="password" type="password" name="password">

    {% if account is defined %}
        {{ errorList(account.getErrors('password')) }}
    {% endif %}

    <button type="submit" class="button">Save and continue</button>

</form>

{% endblock %}

My config file looks like this:

return array(
    'devMode' => true,
    'useEmailAsUsername' => true,
    'autoLoginAfterAccountActivation' => true,
    'omitScriptNameInUrls' => true,
    'setPasswordPath' => array(
        'en' => 'account/setpassword'
    ),
);
  • So, if it's redirecting to the homepage and they are logged in, you're saying that it also skips the whole activation/email verification process altogether, correct? Anything in craft/storage/runtime/logs ? – Chase Giunta Dec 16 '15 at 19:50
  • Yes, I've turned off Verify email addresses in admin/settings/users/settings so it doesn't verify anything. I'll check the logs now. – Cavell Blood Dec 16 '15 at 19:54
  • @ChaseGiunta I checked the logs for redirect and I found this $_POST=array ( 'action' => 'users/saveUser' 'redirect' => 'volunteer/identity' 'firstName' => 'qwetr' 'lastName' => 'erty' 'email' => 'fdgh@me.com' 'password' => REDACTED ) So it looks like it is getting the correct values. – Cavell Blood Dec 16 '15 at 20:00
2

For Craft 2.6, if a hidden redirect input is set, Craft will now follow it first and fallback to the activateAccountSuccessPath if it's not available.

| improve this answer | |
  • Thanks Brad! When is 2.6 coming out? soonish? Looks like Craft is only at 2.5.2757. Is there something I can do to patch it at the moment? – Cavell Blood Jan 12 '16 at 0:10
  • No ETA on 2.6, but hit up support@craftcms.com for the patched file if you want it. Just keep in mind that an auto-update could overwrite it at anytime, though. – Brad Bell Jan 12 '16 at 0:24
  • That's true. Ok, I'll send for a patched file. Thanks. – Cavell Blood Jan 12 '16 at 0:26
  • The patched file fixed this problem. – Cavell Blood Jan 12 '16 at 23:36
0

This probably isn't the answer you're looking for (it should be honoring your redirect) but if that's the only form being used for registrations, you could set 'activateAccountSuccessPath' => 'volunteer/identity' in your config file.

| improve this answer | |
  • Yes, that's true. It should be honoring the redirect. I can try that for now but I'd rather not hard code this. This should work for now. Thanks! – Cavell Blood Dec 16 '15 at 20:36
  • I have the same issue as OP, and since we work with e-mail address verification, this workaround isn't suitable. It should honor the right settings, indeed. – tom Dec 23 '15 at 10:43
  • @tom: I emailed support@craftcms.com and they sent me a patched file that fixed the issue for now. – Cavell Blood Jan 12 '16 at 23:36
  • @cavellblood Thank you for this heads-up. Very helpful. I will mail them too. – tom Jan 15 '16 at 9:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.