Access first name of user in WooCommerce account acitivation mail (DOI via WooCommerce Germanized)

First you need to find the user. I assume you don't have access to the user ID, if you do you can skip the first line, and insert the user_id at the appropriate point.

Then you need to get the first name from the meta data. According to your code you store it in the metadata field 'billing_first_name'. And then it's a matter of inserting it in your email.


$the_user = get_user_by('login', $user_login);
$first_name = get_user_meta($the_user->ID, 'billing_first_name', true);

<p><?php printf( __( 'Hi %s,', 'woocommerce' ), esc_html( $first_name ) ); ?></p>

Actually WooCommerce has that template on default, which includes username, email, myaccount url and much more, I dont think there will be difference between woc eng or grmn, except language.

defined('ABSPATH') || exit;

do_action('woocommerce_email_header', $email_heading, $email); ?>

//To get user_name on registration you need to call get_user_by('id',$user_login); OR get_user_by('login',$user_login); OR get_user_by('user_name',$user_login);

$user = get_user_by('id',$user_login);
$first_name = get_user_meta($user,'first_name',true);

//and call like this

<p><?php printf(esc_html__('Hi %s,', 'woocommerce'), esc_html($first_name)); ?></p>
//translators: %s: Customer username 
<p><?php printf(esc_html__('Hi %s,', 'woocommerce'), esc_html( $user_login)); ?>
//translators: %1$s: Site title, %2$s: Username, %3$s: My account link

<p><?php printf(esc_html__('Thanks for creating an account on %1$s. Your username is %2$s. You can access your account area to view orders, change your password, and more at: %3$s', 'woocommerce'), esc_html($blogname), '<strong>' . esc_html( $user_login) . '</strong>', make_clickable(esc_url( wc_get_page_permalink('myaccount')))); 

// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 

<?php if ('yes' === get_option('woocommerce_registration_generate_password') && $password_generated) : ?>

//translators: %s: Auto generated password

    <p><?php printf(esc_html__('Your password has been automatically generated: %s', 'woocommerce'), '<strong>' . esc_html($user_pass) .'</strong>'); ?></p>
<?php endif; ?>

//Show user-defined additional content - this is set in each email's settings 

if ($additional_content) {
    echo wp_kses_post(wpautop( wptexturize( $additional_content)));

do_action('woocommerce_email_footer', $email);

Here is the template