Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Confirm Email Link leads to inconclusive page AFTER Confirmation

pwolfepwolfe New
edited February 2014 in Vanilla 2.0 - 2.8

After a user has confirmed their email everything works fine on my forum. However, I will run into an issue if/when a user clicks on the confirmation email url in their email a second time after the initial confirmation. If they do this, it will lead them to a page with the message below:

Confirm Email

We couldn't confirm your email. Check the link in the email we sent you or try sending another confirmation email.

To send another confirmation email click here.

If the user clicks the "here" link, then they will get a BONK error.

My solution would be to simply change the text by creating a definition such as:
$Definition['To send another confirmation email click here.'] = '';

That deletes the last line of text and the link successfully, but I want to edit the message above it to say that the user's email has already been confirmed. What code or definition would I have to change in order to do this?

Comments

  • The text is in the UserModel:

    public function ConfirmEmail($User, $EmailKey) {
          $Attributes = GetValue('Attributes', $User);
          $StoredEmailKey = GetValue('EmailKey', $Attributes);
          $UserID = GetValue('UserID', $User);
    
          if (!$StoredEmailKey || $EmailKey != $StoredEmailKey) {
             $this->Validation->AddValidationResult('EmailKey', '@'.T('Couldn\'t confirm email.',
                'We couldn\'t confirm your email. Check the link in the email we sent you or try sending another confirmation email.'));
             return FALSE;
    

    That mail is always sent when the registration key could not be confirmed. If you change it to "already confirmed" the text will be wrong in other cases.
    Nevertheless you could change the text to be a little more specific. The text is inserted in the code like so:

    T(
       'Couldn\'t confirm email.',
       'We couldn\'t confirm (...) try sending another confirmation email.'
    )
    

    So what you see here is a an abbreviation which helps your locale file not to be messed up with too long texts. The T function allows to enter a shortcode that you can use in locale definition files =>

    $Definition['Couldn\'t confirm email.'] = 'We couldn't confirm. Maybe something went wrong, or you already have confirmed your mailadress.';
    
  • That's exactly what I was looking for. Thanks!

Sign In or Register to comment.