You can change the link text in the password reset email without installing a translation plugin by adding a custom code snippet to your theme’s functions.php
file or in a custom plugin. Here’s how to do it:Step 1: Add Custom Code
- Access Your Theme’s
functions.php
File:
- Go to your WordPress dashboard.
- Navigate to Appearance > Theme Editor.
- Find and open the
functions.php
file for your active theme.
- Add the Following Code:
add_filter('woocommerce_email_subject_customer_reset_password', 'ahirwp_custom_reset_password_email_subject', 10, 2);
function ahirwp_custom_reset_password_email_subject($subject, $user) {
return __('Passwort zurücksetzen', 'your-text-domain'); // Change the subject line here
}
add_filter('woocommerce_email_body_customer_reset_password', 'ahirwp_custom_reset_password_email_body', 10, 2);
function ahirwp_custom_reset_password_email_body($body, $user) {
// Use the text you want for the reset link
$reset_link_text = 'Klicken Sie hier, um Ihr Passwort zurückzusetzen';
$reset_link = '<a href="' . esc_url(wp_lostpassword_url()) . '">' . $reset_link_text . '</a>';
// Replace the default link text with the new one
$body = str_replace('Set your password', $reset_link, $body); // Adjust 'Set your password' to match the exact English text if needed
return $body;
}
Save Changes
- After adding the code, make sure to save the changes to the
functions.php
file.
Thanks
Ahir Hemant