Add Snippet To Project
Are you using Easy Digital Downloads to sell digital products on your WordPress site? Have you ever wished you could personalize the user verification emails that are sent out? In this article, we will show you how to customize the user verification emails in Easy Digital Downloads, allowing you to add your own branding and messaging to enhance the user experience.
function wpturbo_customize_user_verification_email( $email_body ) {
$message = "Dear User,nn";
$message .= "Thank you for registering with our website!nn";
$message .= "To verify your account, please click on the following link:n";
$message .= "<a href="{verification_link}">Verify Account</a>nn";
$message .= "If you did not request this verification, please ignore this email.nn";
$message .= "Regards,n";
$message .= "Your Website Team";
$email_body = str_replace( '[edd_verify_account_message]', $message, $email_body );
return $email_body;
}
add_filter( 'edd_user_verification_email_body', 'wpturbo_customize_user_verification_email' );
The code snippet provided allows you to customize the user verification emails sent by Easy Digital Downloads (EDD) plugin in WordPress.
To begin with, we define a function called wpturbo_customize_user_verification_email() which takes the existing content of the email as a parameter. Inside this function, we create a variable called $message where we store the customized email message.
In our custom message, we start by addressing the user with a greeting: "Dear User,". Next, we express our gratitude for their registration: "Thank you for registering with our website!". We then provide instructions for account verification by incorporating a link that the user needs to click on. We achieve this by appending the verification link to the message variable using the {verification_link} placeholder.
To make sure the user knows how to handle the verification email, we include a statement informing them to ignore the email if they did not request this verification.
Finally, we conclude the email message by including a signature from "Your Website Team".
To apply this custom message to the EDD user verification email, we use the str_replace() function. Within this function, we target the placeholder [edd_verify_account_message] in the email body and replace it with our customized message stored in the $message variable.
To bring it all together, we use the add_filter() function to hook our wpturbo_customize_user_verification_email() function into the edd_user_verification_email_body filter. This ensures that our function is applied whenever EDD generates the user verification email.
By utilizing this code snippet, you can easily customize the content of the user verification emails sent by the Easy Digital Downloads plugin in WordPress, giving them a personal touch or aligning them with your brand standards.
