Zuerst müssen Sie diesen Aktivierungscode in den Benutzer-Metadaten registrieren.
Zum Beispiel im Code etwas mit wie:
// Set your activation code in the user meta
$activation_code = 'dHu12548-oh$r' // example for a generated activation code
// Saving the activation code in user meta data.
update_user_meta($user_id, 'activation_code', $activation_code);
Dann können Sie eine benutzerdefinierte Funktion in woocommerce_email_header Aktion Haken gehakt verwenden:
add_action('woocommerce_email_header', 'custom_email_new_account', 100, 2);
function custom_email_new_account($email_heading, $email) {
if ('customer_new_account' === $email->id){
$user_id = $email->object->ID;
$activation_code = get_user_meta($user_id, 'activation_code', $true);
// Displaying the activation code
printf(__('Here is your activation code: %s', 'woocommerce'), '<strong>' . esc_html($activation_code) . '</strong>');
}
}
-Code geht in function.php Datei Ihres aktiven untergeordneten Themas (oder Themas) oder auch in einer beliebigen Plugin-Datei.
Oder Sie können in der WooCommerce Vorlage customer-new-account.php
diesen ähnlichen Code einfügen:
<?php
if ('customer_new_account' === $email->id){
$user_id = $email->object->ID;
$activation_code = get_user_meta($user_id, 'activation_code', $true);
// Displaying the activation code
printf(__('Here is your activation code: %s', 'woocommerce'), '<strong>' . esc_html($activation_code) . '</strong>');
}
?>
dank loicTHeAztec –
done..loicTheAztec –