Skip to content

Instantly share code, notes, and snippets.

@eteubert
Created November 7, 2011 13:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eteubert/1344887 to your computer and use it in GitHub Desktop.
Save eteubert/1344887 to your computer and use it in GitHub Desktop.
WordPress: Activation Email Customization
<?php
function change_welcome_mail_loginlink( $welcome_email, $user_id, $password, $meta ) {
$welcome_email = str_replace( 'LOGINLINK', 'http://www.mysite.com/my/custom/login/url', $welcome_email );
return $welcome_email;
}
add_filter( 'update_welcome_user_email', 'change_welcome_mail_loginlink', 10, 4 );
<?php
function change_welcome_mail_loginlink( $welcome_email, $user_id, $password, $meta ) {
return "Welcome to SITE_NAME!\n\nYour account has been activated - yay! You may now log in with the following information:\n\nLogin: USERNAME\nPassword: PASSWORD\n\nWe look forward to your visit at LOGINLINK\n\nYour SITE_NAME Buddies";
}
add_filter( 'update_welcome_user_email', 'change_welcome_mail_loginlink', 10, 4 );
<?php
/**
* Notify a user that her account activation has been successful.
*
* Filter 'wpmu_welcome_user_notification' to disable or bypass.
*
* Filter 'update_welcome_user_email' and 'update_welcome_user_subject' to
* modify the content and subject line of the notification email.
*
* @since MU
*
* @param int $user_id
* @param string $password
* @param array $meta Optional. Not used in the default function, but is passed along to hooks for customization.
* @return bool
*/
function wpmu_welcome_user_notification($user_id, $password, $meta = '') {
/* ... */
$welcome_email = apply_filters( 'update_welcome_user_email', $welcome_email, $user_id, $password, $meta);
$welcome_email = str_replace( 'SITE_NAME', $current_site->site_name, $welcome_email );
$welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
$welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );
$welcome_email = str_replace( 'LOGINLINK', wp_login_url(), $welcome_email );
/* ... */
}
@lonchbox
Copy link

Thanx for the code. You know if is possible to change the activation email?, the one that is sent before the welcome email, have this text:

Hi,
You've been invited to join '' at
http://mydomain.com with the role of Editor.
If you do not want to join this site please ignore
this email. This invitation will expire in a few days.

Please click the following link to activate your user account:
http://mydomain.com/wp-activate.php?key=0b1c55b36947988b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment