Как отправить письмо для активации аккаунта на языке клиента?
add_action( 'user_register', 'my_registration', 10, 2 );
function my_registration( $user_id ) {
// get user data
$user_info = get_userdata($user_id);
// create md5 code to verify later
$code = md5(time());
// make it into a code to send it to user via email
$string = array('id'=>$user_id, 'code'=>$code);
// create the activation code and activation status
update_user_meta($user_id, 'account_activated', 0);
update_user_meta($user_id, 'activation_code', $code);
// create the url
$url = get_site_url(). '/my-account/?act=' .base64_encode( serialize($string));
// basically we will edit here to make this nicer
$html = '[:en]Please click the following links[:ru]Пожалуйста, нажмите на следующие ссылки[:] <br/><br/> <a href="'.$url.'">'.$url.'</a>';
// send an email out to user
wp_mail( $user_info->user_email, __('Odels','text-domain') , $html);
}
С помощью этого кода отправлю письмо для активации аккаунта, но он должен отправляться на языке клиента, сейчас выводит сам шорткод([:en]Please click[:ru]Пожалуйста, нажмите =[:]), а не текст перевода например(Please click the following links) для ЕN.
Как отправить письмо на языке клиента? Возможно вы знаете другие способы как это можно реализовать?
Cайт на Wordpress. Плагин перевода q translate x
Ответы (1 шт):
Автор решения: WP Punk
→ Ссылка
Судя по коду [:en]...[:ru]...[:] у вас шорткод. Но вы их не выполняете. Используйте функцию do_shortcode, чтобы выполнить все шорткоды в строке:
...
html = do_shortcode( '[:en]Please click the following links[:ru]Пожалуйста, нажмите на следующие ссылки[:] <br/><br/> <a href="'.$url.'">'.$url.'</a>' );
...