Search code examples
phpwordpressemailurlclickable

Email send not clickable url after registration PHP


my problem is in the email sent after users registration. While you get an email for your account verification there is a link you need to visit with your browser to verify your account.

This link is not clickable, you have to copy and paste it into your browser. But I need to make it clickable. I found the source of the link in my php files.

Source code of the link in the email verification

'.get_bloginfo('url').'/?ekey='.$emailhash;

The whole source is

                $body = _d('Hello',17).' '.$yourname.'<br /><br />
'._d('Before you can use the site you will need to validate your email address.',795).'
'._d('If you don\'t validate your email in the next 3 days your account will be deleted.',960).'<br /><br />
'._d('Please validate your email address by clicking the link bellow',1025).': </br>
<a href="<?php echo get_bloginfo('url') . '/?ekey=' . $emailhash; ?>">some link</a>

                escort_email("", "", $youremail, _d('Email validation link',1026)." ".get_option("email_sitename"), $body); 

Is there any way to make it clickable as the a href tag or something like that?

Thank you.


Solution

  • HTML anchors look like this

    <a href="http://www.example.com">some link</a>
    

    You are going to need to concatenate on the link that you want to display which is..

    get_bloginfo('url') . '/?ekey=' . $emailhash
    

    so that it replaces the "example.com link above.

    You can do it like this...

    <a href="<?php echo get_bloginfo('url') . '/?ekey=' . $emailhash; ?>">some link</a>
    

    EDIT: Try this code:

    In response to the opies updated code... your anchor tag was already being echoed out inside of php tags so a solution like this:

    <?php    
    <a href="<?php echo get_bloginfo('url') . '/?ekey=' . $emailhash; ?>">some link</a>
    ?>
    

    is going to fail because we can't have nested <?php ?> tags.

    The solution is to simply concatenate the values that you want into the echoed html like this:

    $body = _d('Hello', 17) . ' ' . $yourname . '
    <br />
    <br />
    ' . _d('Before you can use the site you will need to validate your email address.',795) . '
    ' . _d('If you don\'t validate your email in the next 3 days your account will be deleted.',960).'<br /><br />
    ' . _d('Please validate your email address by clicking the link bellow',1025). ':
    </br>
    <a href="' . get_bloginfo('url') . '/?ekey=' . $emailhash . '">some link</a>';
    
    escort_email("", "", $youremail, _d('Email validation link',1026)." ".get_option("email_sitename"), $body);