I needed to change two strings shown to the user on the site upon clicking the confirmation links in the email (not to modify the emails sent out). I made the following modifications and it worked.:

    --- wp-activate.bak        2017-02-28 13:01:03.883175677 +0530
    +++ wp-activate.php     2017-02-28 13:47:35.000000000 +0530
    @@ -13,6 +13,10 @@ require( dirname(__FILE__) . '/wp-load.p

     require( dirname( __FILE__ ) . '/wp-blog-header.php' );

    +// Changes the header
    +require( dirname(__FILE__) . '/wp-custommsg.php' );
     if ( !is_multisite() ) {
            wp_redirect( wp_registration_url() );
    @@ -128,7 +132,7 @@ get_header( 'wp-activate' );
                            $url = isset( $result['blog_id'] ) ? get_home_url( (int) $result['blog_id'] ) : '';
                            $user = get_userdata( (int) $result['user_id'] );
    -                       <h2><?php _e('Your account is now active!'); ?></h2>
    +                       <h2><?php _e($active_page_title); ?></h2>

                            <div id="signup-welcome">
                                    <p><span class="h3"><?php _e('Username:'); ?></span> <?php echo $user->user_login ?></p>
    @@ -147,7 +151,7 @@ get_header( 'wp-activate' );
                            <?php else: ?>
                                    <p class="view"><?php
                                            /* translators: 1: login URL, 2: network home URL */
    -                                       printf( __( 'Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.' ), network_site_url( 'wp-login.php', 'login' ), network_home_url() );
    +                                       printf( __( $active_page_msg ), network_site_url( 'wp-login.php', 'login' ), network_home_url() );
                            <?php endif;

And wp-custommsg.php contains:


$active_page_title = 'My custom title';
$active_page_msg = 'My custom message';

I tried to read about hooks and actions but can't seem to wrap my head around them. How can I convert my changes into a plugin so that it survives a wordpress version update?

To clarify, these modifications reside in html code outside of the php content in wp-activate.php, and as far as I can see, do not have hooks.


I haven't done this kind of a hook yet but I did find this page in the wordpress codex


They do explain a bit their about how you can modify the content of the activation and notifcation emails

I will try to explain a bit here In Wordpress an Action is a type of hook. You get Action Hooks and Filter Hooks

Actions are triggered by specific events that happen in Wordpress like when a post is published you can trigger a custom action. Linked to a function that handles what you need it to do. An idea here is say for instance you would like to update a third party database when a specific post is updated you could link that to an action. Actions are hooks to Wordpress using add_action()

Filters are functions defined for Wordpress to run data through as it is displayed. So say for instance you would like to change some text on a post without affecting the database you would use a filter. That way when you change the filter you don't have to edit the actual database values of the posts. Filters are hooked into wordpress using add_filter()

For more information I think have a read at this page https://codex.wordpress.org/Plugin_API which explains more in details about Hooks.

  • For full lists of either actions or filters to hook to you can view the links below Actions - codex.wordpress.org/Plugin_API/Action_Reference Filters - codex.wordpress.org/Plugin_API/Filter_Reference
    – marwyk87
    Feb 28 '17 at 19:20
  • Yes, I know that the emails have hooks. However I need to modify the text that is displayed on the site when a user is activated. And this seems to be html code outside any of the php code (or hooks). Mar 1 '17 at 4:44
  • Oh apologies misunderstood the question. Here is a list of all plugin hooks in WP4.4 adambrown.info/p/wp_hooks/version/4.4 Maybe there is one that allows you to add a filter to the html displayed messages after activation email link is followed? I will also have a look and run a test on that
    – marwyk87
    Mar 1 '17 at 5:59
  • As far as I can see there is something you could try out. vanbodevelops.com/tutorials/… This is an example of how to bypass the activation page using the hook activate_header. Maybe if you use this hook you can modify the activation page as well or redirect to your own plugin activation page or something? Another example is here maybe wordpress.stackexchange.com/questions/41329/… I haven't had time to test so hopefully this helps you out.
    – marwyk87
    Mar 1 '17 at 6:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.