<p>In Craft when changing an email address (even if it's the currently logged in user), they must supply their existing password as well.  You can use the hidden <code>redirect</code> input to send to whatever template you want (assuming saving the user was successful).  In your case, then template can tell them to check their email and click the link it contains.</p>

<pre><code>&lt;form method="post" accept-charset="UTF-8"&gt;
    {{ getCsrfInput() }}

    &lt;input type="hidden" name="action" value="users/saveUser"&gt;
    &lt;input type="hidden" name="redirect" value="users/checkyouremail"&gt;
    &lt;input type="hidden" name="userId" value="{{ currentUser.id }}"&gt;

    &lt;input type="text" name="email" value="{{ currentUser.email }}"&gt;
    &lt;input id="password" type="password" name="password"&gt;

    &lt;input type="submit" value="Save Profile"&gt;
&lt;/form&gt;
</code></pre>

<p>Once the click the link and verify they own the email address, they'll get redirected to the site root.</p>

<p>If you need different behavior than that, you can always write a plugin that has it's own controller actions that changes the workflow into something you need.</p>

CC BY-SA 3.0
2016-01-06T19:58:46.867Z
Hi Brad, Thanks for the answer! I'm currently using the redirect hidden input to send them to the same profile page they've been editing from and I use `craft.session.getFlash('notice')` to verify what they've done. IE, a return of "User saved." means they updated their profile. Unfortunately changing emails is optional in this profile form so I would actually need a way to validate through some sort of flash message or something that they actually changed their email (so I could conditionally display Check your email instructions).
Peter Tell
CC BY-SA 3.0
2016-01-06T20:19:55.017Z
In that case a custom plugin is the way to go.  You'd just check if email had a value in POST and if so, set the flash message.
Brad Bell
CC BY-SA 3.0
2016-01-06T20:34:59.697Z
Awesome thanks Brad. I want to give you the check mark because you led to the right answer, but technically for anyone viewing this in the future the custom plugin route and that controller were what were needed to accomplish the task. But please know that in my heart... those are your 50 internet points.
Peter Tell
CC BY-SA 3.0
2016-01-06T20:35:49.680Z
Pfft... I burn my points for warmth!
Brad Bell
CC BY-SA 3.0
2016-01-06T20:57:12.393Z
I thought that's what the whiskey was for ;-) Thanks again!
Peter Tell
CC BY-SA 3.0
2016-01-06T19:50:22.617Z
2016-01-06T19:50:22.617Z
Brad Bell
<p>Based on Brad's response I created the following controller in a plugin:</p>

<pre><code>&lt;?php
namespace Craft;

class Myplugin_SaveUserController extends BaseController
{
    protected $allowAnonymous = true;
    /**
     * Handle the save user form request.
     */
    public function actionSaveUser()
    {
        $this-&gt;requirePostRequest();
        $email  = craft()-&gt;request-&gt;getPost('email');
        $userId = craft()-&gt;request-&gt;getPost('userId');
        $user   = craft()-&gt;users-&gt;getUserById($userId);

        if ($email !== $user-&gt;email)
        {
            craft()-&gt;userSession-&gt;setFlash('changedEmail', 'changed email');
        }
        $this-&gt;forward('users/saveUser', false);
    }
}
</code></pre>

<p>I then check for it in my template:</p>

<pre><code>{% if craft.session.getFlash('changedEmail') == 'changed email' %}
</code></pre>

<p>This seems to do the job.</p>

<p>For anyone who may be using this in the future, it's worth noting that I also had to change the "action" hidden input in my form:</p>

<pre><code>&lt;input type="hidden" name="action" value="myplugin/saveUser/saveUser"&gt;
</code></pre>

CC BY-SA 3.0
2016-01-06T20:25:51.067Z
2016-01-06T20:25:51.067Z
Peter Tell
<p>I have a profile form where a user can update their email.</p>

<p>Upon doing so I would like to:</p>

<ol>
<li>Show the user a message saying they must check their email to verify the new email address.</li>
<li>After they click the "Verify Email" address in their inbox, redirect them to a url preferably with a Flash Message letting them know they'e successfully updated their email.</li>
</ol>

<p>Possible?</p>

<user-profile>
How would I show a message and define where the user is redirected after changing their email through a front end form?
# How would I show a message and define where the user is redirected after changing their email through a front end form?

(Asked by: username_0 on 2015-12-28)

I have a profile form where a user can update their email.

Upon doing so I would like to:

1. Show the user a message saying they must check their email to verify the new email address.
2. After they click the "Verify Email" address in their inbox, redirect them to a url preferably with a Flash Message letting them know they'e successfully updated their email.

Possible?

**Tags:** user-profile

---

## 2 answers

### Answer by username_0 on 2016-01-06. Score: 5 | Accepted answer

Based on Brad's response I created the following controller in a plugin:
requirePostRequest();
        $email  = craft()->request->getPost('email');
        $userId = craft()->request->getPost('userId');
        $user   = craft()->users->getUserById($userId);

        if ($email !== $user->email)
        {
            craft()->userSession->setFlash('changedEmail', 'changed email');
        }
        $this->forward('users/saveUser', false);
    }
}

I then check for it in my template:
{% if craft.session.getFlash('changedEmail') == 'changed email' %}

This seems to do the job.
For anyone who may be using this in the future, it's worth noting that I also had to change the "action" hidden input in my form:


---

### Answer by username_1 on 2016-01-06. Score: 4

In Craft when changing an email address (even if it's the currently logged in user), they must supply their existing password as well.  You can use the hidden redirect input to send to whatever template you want (assuming saving the user was successful).  In your case, then template can tell them to check their email and click the link it contains.

    {{ getCsrfInput() }}

    
    
    

    
    

    


Once the click the link and verify they own the email address, they'll get redirected to the site root.
If you need different behavior than that, you can always write a plugin that has it's own controller actions that changes the workflow into something you need.

> **Comments:**
> **username_0**: Hi Brad, Thanks for the answer! I'm currently using the redirect hidden input to send them to the same profile page they've been editing from and I use `craft.session.getFlash('notice')` to verify what they've done. IE, a return of "User saved." means they updated their profile. Unfortunately changing emails is optional in this profile form so I would actually need a way to validate through some sort of flash message or something that they actually changed their email (so I could conditionally display Check your email instructions).  
> **username_1**: In that case a custom plugin is the way to go.  You'd just check if email had a value in POST and if so, set the flash message.  
> **username_0**: Awesome thanks Brad. I want to give you the check mark because you led to the right answer, but technically for anyone viewing this in the future the custom plugin route and that controller were what were needed to accomplish the task. But please know that in my heart... those are your 50 internet points.  
> **username_1**: Pfft... I burn my points for warmth!  
> **username_0**: I thought that's what the whiskey was for ;-) Thanks again!  

---

