Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Customize user account activation message

I’ve found the answer here:
Customizing wp-activate.php

It’s a bit of a workaround really, but it works pretty well.

Step 1
Create a new page called ‘activate’

Step 2
Create a new template called ‘template-activate.php’ and add the following code:

**Template (template-activate.php)**
<?php
/**
 * Template Name: Activation
 *
 */

/**
 * Confirms that the activation key that is sent in an email after a user signs
 * up for a new blog matches the key for that user and then displays confirmation.
 *
 * @package WordPress
 */

if ( !is_multisite() OR (empty($_GET['key']) && empty($_POST['key'])) ) {
    wp_redirect( site_url( '/wp-login.php?action=register' ) );
    die();
}

if ( is_object( $wp_object_cache ) )
    $wp_object_cache->cache_enabled = false;

// Fix for page title
$wp_query->is_404 = false;

/**
 * Fires before the Site Activation page is loaded.
 *
 * @since 3.0
 */
do_action( 'activate_header' );

/**
 * Adds an action hook specific to this page that fires on wp_head
 *
 * @since MU
 */
function do_activate_header() {
    /**
     * Fires before the Site Activation page is loaded, but on the wp_head action.
     *
     * @since 3.0
     */
    do_action( 'activate_wp_head' );
}
add_action( 'wp_head', 'do_activate_header' );

get_header();

//theme specific (CoWorker)
get_template_part( 'include/content', 'head' );
?>

<?php
        $key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key'];
        $result = wpmu_activate_signup($key);
      $siteurl = site_url();
      $lostpassword = $siteurl.'/lostpassword';
        if ( is_wp_error($result) ) {
            if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
                $signup = $result->get_error_data();
                ?>
                <h2><?php _e('Your account is now active!'); ?></h2>
                <?php
                echo '<p class="lead-in">';
                if ( $signup->domain . $signup->path == '' ) {
                    printf( __('You may now <a href="https://wordpress.stackexchange.com/questions/126926/%1$s">log in</a> to the site using your chosen username of <strong>&#8220;%2$s&#8221;</strong>.</p><p>Please check your email inbox at <strong>%3$s</strong> for your password and login instructions.</p></p>If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.</p>'), $siteurl.'/login', $signup->user_login, $signup->user_email, $lostpassword );
                } else {
                    printf( __('Your site at <a href="https://wordpress.stackexchange.com/questions/126926/%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of <strong>&#8220;%3$s&#8221;</strong>.</p><p>Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, $lostpassword );
                }
                echo '</p>';
            } else {
                ?>
                <h2><?php _e('An error occurred during the activation'); ?></h2>
                <?php
                echo '<p>'.$result->get_error_message().'</p>';
            }
        } else {
            extract($result);
            $url = get_blogaddress_by_id( (int) $blog_id);
            $user = get_userdata( (int) $user_id);
         $username = $user->user_login;
         $useremail = $user->user_email;
            ?>
            <h2><?php _e('Your account is now active!'); ?></h2>

            <div id="signup-welcome">
              <p class="view"><?php printf( __('You may now <a href="https://wordpress.stackexchange.com/questions/126926/%1$s">log in</a> to the site using your chosen username of <strong>&#8220;%2$s&#8221;</strong>.</p><p>Please check your email inbox at <strong>%3$s</strong> for your password and login instructions.</p></p>If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.</p>'), $siteurl.'/login', $username, $useremail, $lostpassword ); ?></p>
         </div>
            <?php
        }
    ?>

<script type="text/javascript">
    var key_input = document.getElementById('key');
    key_input && key_input.focus();
</script>

<?php
//theme specific (CoWorker)
get_template_part( 'include/content', 'foot' ); 

get_footer();
?>  

Step 3
Create a new plugin file called ‘custom-activation-email.php’

<?php 
/*
Plugin Name: Custom Activation Email
Plugin URI: YOUR URL
Description: Plugin to customize the automated user account activation email
Author: ME
Version: 1.0
Author URI: YOUR URL
*/
    add_filter( 'wpmu_signup_user_notification', 'kc_wpmu_signup_user_notification', 10, 4 );
    function kc_wpmu_signup_user_notification($user, $user_email, $key, $meta="") {
        $sitename = get_bloginfo( 'name' );
        $blog_id = get_current_blog_id();
        // Send email with activation link.
        $admin_email = get_option( 'admin_email' );
        if ( $admin_email == '' )
            $admin_email="support@" . $_SERVER['SERVER_NAME'];
        $from_name = get_option( 'blogname' ) == '' ? $sitename : esc_html( get_option( 'blogname' ) );
        $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
        $message = sprintf(
            apply_filters( 'wpmu_signup_user_notification_email',
                __( "Hi %s,\n\nThank you for registering with %s.\n\nTo activate your account, please click the following link:\n\n%s\n\nYou will then receive an email with your login details." ),
                $user, $user_email, $key, $meta
            ),
            $user,
            $sitename,
            site_url( "activate/?key=$key" )


        );
        // TODO: Don't hard code activation link.
        $subject = sprintf(
            apply_filters( 'wpmu_signup_user_notification_subject',
                __( '%3$s - Activate your account' ),
                $user, $user_email, $key, $meta
            ),
            $from_name,
            $user,
            $sitename
        );
        wp_mail($user_email, $subject, $message, $message_headers);

        return false;
    }
?>

Notes
I’m using the ‘Theme My Login’ plugin, hence the changed links to /login and /lostpassword.
I chose to do step 3 as a plugin instead of adding to my theme’s functions.php because I didn’t seem to work that way.

Related Posts:

  1. Removing labels and tag on WordPress’s default login form
  2. add filter login_redirect does not contain original requested redirect
  3. Change username before login
  4. How do I hook my function to run only after submitting login form
  5. Change password reqts with NO plugin without breaking resetpass link?
  6. WordPress hooks/filters insert before content or after title
  7. How do filters and hooks really work in PHP
  8. Trouble understanding apply_filters()
  9. How many filter/action hooks are healthy?
  10. Filter specific shortcode output?
  11. Earliest hook to reliably get $post/$posts
  12. How to pass/get data to/from the WooCommerce data-product_variations object?
  13. Where to hook into post content?
  14. What does (10, 2) mean when used with add_filter
  15. Clarification on filters and hooks
  16. Valid characters for actions, hooks and filters
  17. How to hook into unregistering a widget instance?
  18. How to check if a hook is hooked or not?
  19. Editing ‘Password Reset’ E-mail
  20. Passing Additional Parameters to add_filter Callable
  21. What hook do I use to edit the post statuses option in admin?
  22. Filter hook before create order WooCommerce
  23. Modify WordPress Rest Api Request/Response
  24. How to add some custom HTML into wordpress admin bar?
  25. Custom theme hooks / filters – passing arguments
  26. wp_mail – Remove sitename from email subject
  27. How to disable all WordPress emails modularly and programatically?
  28. How to hook wp_list_pages?
  29. apply_filters() slices away needed arguments
  30. WP Rest API – Upload media without saving attachment post
  31. How to make post and comment count unclickable with dashboard_glance_items hook
  32. How to use the_excerpt in a filter hook?
  33. Change the footer text on the login page
  34. How to add attribute to output with wp_video_shortcode add_filter
  35. How to change Woocommerce breadcrumbs content?
  36. Change “You are now logged out” text
  37. Hook into admin post list page
  38. Anyway to edit the titlebar of WordPress Widgets in the Admin area?
  39. How to limit the pages displayed for choosing parent page on page attribute’s menu?
  40. How can I hide all posts that don’t have a thumbnail?
  41. Change text of Description in Image Library
  42. Load different template file when condition met?
  43. Am I using the right hook for removing quicktags on the admin TinyMCE?
  44. About Hooks and Filters
  45. How to enable visual editor when editing comments on the dashboard?
  46. Should I use add_action(‘publish_post or add_filter(‘publish_post?
  47. Please explain me what the do_action does
  48. Is it possible to Hook/Filters Attachment Creation?
  49. Filter all html output
  50. Can’t get wp_title filter working in twenty sixteen child theme
  51. wpmu_signup_user_notification filter not working
  52. How can I reliably and globally disable wptexturize?
  53. Customise Jetpack Publicize text
  54. WordPress RSS feed – filter RSS content by custom field value
  55. How to trigger the core WPLANG to make automatically set a language when the theme is activated? [duplicate]
  56. How to hook some Unicode texts into calendar widget safely?
  57. How to add attributes to tag when template cannot be directly modified
  58. filter the_title problem in nav
  59. How can I add a fifth option to the alignment picker?
  60. Too many actions/filters!
  61. Filter the URL of next_posts_link & previous_posts_link
  62. How to get list of all hooks of current theme / plugin?
  63. Which hook is fired when inserting media into a post
  64. How to replace any occurence of Gravatars with a local placeholder image?
  65. How does WordPress call functions attached to a certain action hook before calling functions attached to other hooks
  66. Sensei LMS Hooks to Remove Content
  67. What hook/filter can I use to add/edit/show/hide the title under (on hover) links on the table view?
  68. Conditionally call add_action depending on post_type?
  69. How do we check if the user is logging in or registering?
  70. Customizing the default logout page of WordPress
  71. Change WordPress RSS link with filter?
  72. WordPress tag cloud add more links
  73. Add a header before fields added with the attachment_fields_to_edit() filter
  74. Error when overriding only some audio shortcode HTML output
  75. Hide content editor for posts after approriate date
  76. Why anything done on comments_array hook gets reset?
  77. Gutenberg disable the “block” tab in right sidebar
  78. Why my admin doesn’t work after adding rest_prepare_post filter?
  79. add_filter() function misunderstanding
  80. Is it possible to track down Actions and Filters?
  81. When to use actions and when to use filters
  82. add_filter to ‘woocommerce_before_main_content’ [closed]
  83. Yoast SEO hooks overriding themselves
  84. Editing
  85. Is possible dequeue/remove style from wp_footer() hook and add on wp_head() hook?
  86. Same Conditionals Not Working on Two Different Hooks
  87. Filter or Hook to catch pre-rendering of post content
  88. How to call a function or method that is Namespaced using another plugin
  89. get_header and hook avoid normal call
  90. Question about how do wordpress filters/actions work
  91. How to center oEmbedded content
  92. How to add numeric slug for child page in WordPress 5.9?
  93. Can the wp_filter object hold multiple values with the same key
  94. check to see if hook is available
  95. How to change the order (priority) of registered filters (or actions) (e.g. for the_content)?
  96. apply_filters/do_action tag characters limit
  97. Custom Login Errors and variables I can use
  98. How do I target a single page to modify the comment form of only that page?
  99. How to change the order of HTML output of a core block?
  100. Filter taxonomy admin pagination
Categories filters Tags activation, filters, hooks, login
How to add a privacy-checkbox in comment-template?
How do I change the default WordPress e-mail ID for sent e-mail?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress