简体   繁体   中英

How to make a Variable clickable in php file

I have a php template file created by this Front End Reset Password plugins. Here is original part of the template I would like to acheive:

$reset_url = som_get_lost_password_url() . "?somresetpass=true&action=rp&key=$key&login=" . rawurlencode($user_login);

$message = __( 'Someone requested that the password be reset for the following account:', 'frontend-reset-password' ) . "<br><br>";
$message .= sprintf( __( 'Username: %s', 'frontend-reset-password' ), $user_login ) . "<br><br>";
$message .= home_url( '/' ) . "<br><br>";
$message .= __( 'If this was a mistake, just ignore this email and nothing will happen.', 'frontend-reset-password' ) . "<br><br>";
$message .= __( 'To reset your password, visit the following address:', 'frontend-reset-password' ) . "<br><br>";
//$message .= network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . "\r\n";

// replace PAGE_ID with reset page ID $_GET['somresetpass']
$message .= $reset_url;

Here is what I try to achieve:

$reset_url = som_get_lost_password_url() . "?somresetpass=true&action=rp&key=$key&login=" . rawurlencode($user_login);

$message = __( 'Someone requested that the password be reset for the following account:', 'frontend-reset-password' ) . "<br><br>";
$message .= sprintf( __( 'Username: %s', 'frontend-reset-password' ), $user_login ) . "<br><br>";
$message .= home_url( '/' ) . "<br><br>";
$message .= __( 'If this was a mistake, just ignore this email and nothing will happen.', 'frontend-reset-password' ) . "<br><br>";
$message .= __( 'To reset your password, visit the following address:', 'frontend-reset-password' ) . "<br><br>";
//$message .= network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . "\r\n";

// replace PAGE_ID with reset page ID $_GET['somresetpass']
$message .= sprintf(__( '<a href="$reset_url">Reset Your Password</a>', 'frontend-reset-password' ) );

I have change the last line to make it URL, but it is not clickable in an email when this message is sent to users after they submit a Password Reset form.

How can I make it clickable in an email?

many thanks, aynber. It works well; I just did what you say like this:

$message .= sprintf(__( "<a href='$reset_url'>Reset Your Password</a>", 'frontend-reset-password' ) );

May I ask another question for the same function? I try to figure out how to send the above link based on languages to users after they submit a Password Reset form. I use Polylang built-in theme, and could not separate in this way:

if (get_locale() == "en_US") {
//send the codes above
}
else {
//send message above in French and change this URL to: home_url()/fr/ ..?
}

Because the above default URL does not separate between home URL and its page; is it possible to achieve that?

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM