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]Пожалуйста, нажмите =[:]),而不是例如翻译文本(请点击以下链接) CN.
如何以客户的语言发送电子邮件?你知道其他方法吗?
WordPress 上的网站。q 翻译 x 翻译插件
从代码来看,
[:en]...[:ru]...[:]您有一个简码。但你不做。使用该函数do_shortcode执行字符串中的所有短代码: