Make WordPress Core

Ticket #28352: wp-activate.patch

File wp-activate.patch, 6.0 KB (added by UmeshSingla, 11 years ago)

Added filters to display a custom user or blog activation message

  • wp-activate.php

     
    8686                $key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key'];
    8787                $result = wpmu_activate_signup( $key );
    8888                if ( is_wp_error($result) ) {
    89                         if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
    90                             $signup = $result->get_error_data();
    91                                 ?>
    92                                 <h2><?php _e('Your account is now active!'); ?></h2>
    93                                 <?php
    94                                 echo '<p class="lead-in">';
    95                                 if ( $signup->domain . $signup->path == '' ) {
    96                                         printf( __('Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$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="%4$s">reset your password</a>.'), network_site_url( 'wp-login.php', 'login' ), $signup->user_login, $signup->user_email, wp_lostpassword_url() );
     89                        /**
     90                         * Filter the signup activation error message
     91                         *
     92                         * @since 4.0
     93                         *
     94                         * @param string $message
     95                         * @param string $result->get_error_code(), error code received while activating the user or blog
     96                         * @param array $result, An array containing information about the activated user and/or blog
     97                         */
     98                        $message = apply_filters ( 'signup_activation_error', $message = '', $result->get_error_code(), $result );
     99                        if ( $message ) {
     100                                echo $message;
     101                        }else {
     102                                if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
     103                                        $signup = $result->get_error_data();
     104                                        ?>
     105                                        <h2><?php _e( 'Your account is now active!' ); ?></h2>
     106                                        <?php
     107                                        echo '<p class="lead-in">';
     108                                        if ( $signup->domain . $signup->path == '' ) {
     109                                                printf( __( 'Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$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="%4$s">reset your password</a>.' ), network_site_url( 'wp-login.php', 'login' ), $signup->user_login, $signup->user_email, wp_lostpassword_url() );
     110                                        } else {
     111                                                printf( __( 'Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of &#8220;%3$s&#8221;. 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, wp_lostpassword_url() );
     112                                        }
     113                                        echo '</p>';
    97114                                } else {
    98                                         printf( __('Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of &#8220;%3$s&#8221;. 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, wp_lostpassword_url() );
     115                                        ?>
     116                                        <h2><?php _e( 'An error occurred during the activation' ); ?></h2>
     117                                        <?php
     118                                        echo '<p>' . $result->get_error_message() . '</p>';
    99119                                }
    100                                 echo '</p>';
    101                         } else {
    102                                 ?>
    103                                 <h2><?php _e('An error occurred during the activation'); ?></h2>
    104                                 <?php
    105                             echo '<p>'.$result->get_error_message().'</p>';
    106120                        }
    107121                } else {
    108122                        $url = get_blogaddress_by_id( (int) $result['blog_id'] );
    109123                        $user = get_userdata( (int) $result['user_id'] );
    110                         ?>
    111                         <h2><?php _e('Your account is now active!'); ?></h2>
     124                        /**
     125                         * Filter the activation success message
     126                         *
     127                         * @since 4.0
     128                         *
     129                         * @param string $message
     130                         * @param string $url, site url
     131                         * @param object $user, WP_User object
     132                         * @param array $result, An array containing information about the activated user and/or blog
     133                         */
     134                        $message = apply_filters ( 'signup_activation_success', $message = '', $url, $user, $result );
     135                        if ( $message ) {
     136                                echo $message;
     137                        }else {
     138                                ?>
     139                                <h2><?php _e( 'Your account is now active!' ); ?></h2>
    112140
    113                         <div id="signup-welcome">
    114                                 <p><span class="h3"><?php _e('Username:'); ?></span> <?php echo $user->user_login ?></p>
    115                                 <p><span class="h3"><?php _e('Password:'); ?></span> <?php echo $result['password']; ?></p>
    116                         </div>
     141                                <div id="signup-welcome">
     142                                        <p><span class="h3"><?php _e( 'Username:' ); ?></span> <?php echo $user->user_login ?></p>
    117143
    118                         <?php if ( $url != network_home_url('', 'http') ) : ?>
    119                                 <p class="view"><?php printf( __('Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>'), $url, $url . 'wp-login.php' ); ?></p>
    120                         <?php else: ?>
    121                                 <p class="view"><?php 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() ); ?></p>
    122                         <?php endif;
     144                                        <p><span class="h3"><?php _e( 'Password:' ); ?></span> <?php echo $result['password']; ?></p>
     145                                </div>
     146
     147                                <?php if ( $url != network_home_url( '', 'http' ) ) : ?>
     148                                        <p class="view"><?php printf( __( 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>' ), $url, $url . 'wp-login.php' ); ?></p>
     149                                <?php else: ?>
     150                                        <p class="view"><?php 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() ); ?></p>
     151                                <?php endif;
     152                        }
    123153                }
    124154        }
    125155        ?>