Skip to:
Content

BuddyPress.org

Ticket #6049: 6049.diff

File 6049.diff, 6.7 KB (added by boonebgorges, 4 years ago)
  • src/bp-core/bp-core-template.php

    diff --git a/src/bp-core/bp-core-template.php b/src/bp-core/bp-core-template.php
    index 21825050f..00b96a5a2 100644
    a b function bp_blog_signup_allowed() { 
    11541154 *              otherwise false.
    11551155 */
    11561156function bp_account_was_activated() {
    1157         $bp                  = buddypress();
    1158         $activation_complete = !empty( $bp->activation_complete )
    1159                 ? $bp->activation_complete
    1160                 : false;
     1157        $activation_complete = ! empty( buddypress()->activation_complete ) || ( bp_is_current_component( 'activate' ) && ! empty( $_GET['activated'] ) );
    11611158
    11621159        return $activation_complete;
    11631160}
  • src/bp-members/bp-members-actions.php

    diff --git a/src/bp-members/bp-members-actions.php b/src/bp-members/bp-members-actions.php
    index 233c3b076..996a86fa1 100644
    a b function bp_core_action_delete_user() { 
    107107        }
    108108}
    109109
     110/**
     111 * Catches and processes account activation requests.
     112 *
     113 * @since 3.0.0
     114 */
     115function bp_members_action_activate_account() {
     116        if ( ! bp_is_current_component( 'activate' ) ) {
     117                return;
     118        }
     119
     120        if ( is_user_logged_in() ) {
     121                return;
     122        }
     123
     124        if ( ! empty( $_POST['key'] ) ) {
     125                $key = wp_unslash( $_POST['key'] );
     126
     127        // Backward compatibility with templates using `method="get"` in their activation forms.
     128        } elseif ( ! empty( $_GET['key'] ) ) {
     129                $key = wp_unslash( $_GET['key'] );
     130        }
     131
     132        if ( empty( $key ) ) {
     133                return;
     134        }
     135
     136        $bp = buddypress();
     137
     138        /**
     139         * Filters the activation signup.
     140         *
     141         * @since 1.1.0
     142         *
     143         * @param bool|int $value Value returned by activation.
     144         *                        Integer on success, boolean on failure.
     145         */
     146        $user = apply_filters( 'bp_core_activate_account', bp_core_activate_signup( $key ) );
     147
     148        // If there were errors, add a message and redirect.
     149        if ( ! empty( $user->errors ) ) {
     150                bp_core_add_message( $user->get_error_message(), 'error' );
     151                bp_core_redirect( trailingslashit( bp_get_root_domain() . '/' . $bp->pages->activate->slug ) );
     152        }
     153
     154        bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
     155        bp_core_redirect( add_query_arg( 'activated', '1', bp_get_activation_page() ) );
     156
     157}
     158add_action( 'bp_actions', 'bp_members_action_activate_account' );
     159
    110160/*
    111161 * Unhooked in 1.6.0 - moved to settings
    112162 * add_action( 'bp_actions', 'bp_core_action_delete_user' );
  • src/bp-members/bp-members-screens.php

    diff --git a/src/bp-members/bp-members-screens.php b/src/bp-members/bp-members-screens.php
    index f7bc436a5..34f7c4e01 100644
    a b add_action( 'bp_screens', 'bp_core_screen_signup' ); 
    290290 * Handle the loading of the Activate screen.
    291291 *
    292292 * @since 1.1.0
    293  *
    294  * @todo Move the actual activation process into an action in bp-members-actions.php
    295293 */
    296294function bp_core_screen_activation() {
    297295
    function bp_core_screen_activation() { 
    325323                bp_core_redirect( $redirect_to );
    326324        }
    327325
    328         // Grab the key (the old way).
    329         $key = isset( $_GET['key'] ) ? $_GET['key'] : '';
    330 
    331         // Grab the key (the new way).
    332         if ( empty( $key ) ) {
    333                 $key = bp_current_action();
    334         }
    335 
    336326        // Get BuddyPress.
    337327        $bp = buddypress();
    338328
    339         // We've got a key; let's attempt to activate the signup.
    340         if ( ! empty( $key ) ) {
    341 
    342                 /**
    343                  * Filters the activation signup.
    344                  *
    345                  * @since 1.1.0
    346                  *
    347                  * @param bool|int $value Value returned by activation.
    348                  *                        Integer on success, boolean on failure.
    349                  */
    350                 $user = apply_filters( 'bp_core_activate_account', bp_core_activate_signup( $key ) );
    351 
    352                 // If there were errors, add a message and redirect.
    353                 if ( ! empty( $user->errors ) ) {
    354                         bp_core_add_message( $user->get_error_message(), 'error' );
    355                         bp_core_redirect( trailingslashit( bp_get_root_domain() . '/' . $bp->pages->activate->slug ) );
    356                 }
    357 
    358                 bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
    359                 $bp->activation_complete = true;
    360         }
    361 
    362329        /**
    363330         * Filters the template to load for the Member activation page screen.
    364331         *
  • src/bp-members/bp-members-template.php

    diff --git a/src/bp-members/bp-members-template.php b/src/bp-members/bp-members-template.php
    index b94cb3033..81cf94075 100644
    a b function bp_activation_page() { 
    21172117                return apply_filters( 'bp_get_activation_page', $page );
    21182118        }
    21192119
     2120/**
     2121 * Get the activation key from the current request URL.
     2122 *
     2123 * @since 3.0.0
     2124 *
     2125 * @return string
     2126 */
     2127function bp_get_current_activation_key() {
     2128        $key = '';
     2129
     2130        if ( bp_is_current_component( 'activate' ) ) {
     2131                if ( isset( $_GET['key'] ) ) {
     2132                        $key = wp_unslash( $_GET['key'] );
     2133                } else {
     2134                        $key = bp_current_action();
     2135                }
     2136        }
     2137
     2138        /**
     2139         * Filters the activation key from the current request URL.
     2140         *
     2141         * @since 3.0.0
     2142         *
     2143         * @param string $key Activation key.
     2144         */
     2145        return apply_filters( 'bp_get_current_activation_key', $key );
     2146}
     2147
    21202148/**
    21212149 * Output the username submitted during signup.
    21222150 *
  • src/bp-templates/bp-legacy/buddypress/members/activate.php

    diff --git a/src/bp-templates/bp-legacy/buddypress/members/activate.php b/src/bp-templates/bp-legacy/buddypress/members/activate.php
    index 975006d0a..a99515e5c 100644
    a b  
    5050
    5151                        <p><?php _e( 'Please provide a valid activation key.', 'buddypress' ); ?></p>
    5252
    53                         <form action="" method="get" class="standard-form" id="activation-form">
     53                        <form action="" method="post" class="standard-form" id="activation-form">
    5454
    5555                                <label for="key"><?php _e( 'Activation Key:', 'buddypress' ); ?></label>
    56                                 <input type="text" name="key" id="key" value="" />
     56                                <input type="text" name="key" id="key" value="<?php echo esc_attr( bp_get_current_activation_key() ); ?>" />
    5757
    5858                                <p class="submit">
    5959                                        <input type="submit" name="submit" value="<?php esc_attr_e( 'Activate', 'buddypress' ); ?>" />
  • src/bp-templates/bp-nouveau/buddypress/members/activate.php

    diff --git a/src/bp-templates/bp-nouveau/buddypress/members/activate.php b/src/bp-templates/bp-nouveau/buddypress/members/activate.php
    index 1b52dab1d..240e86c3a 100644
    a b  
    2525
    2626                        <p><?php _e( 'Please provide a valid activation key.', 'buddypress' ); ?></p>
    2727
    28                         <form action="" method="get" class="standard-form" id="activation-form">
     28                        <form action="" method="post" class="standard-form" id="activation-form">
    2929
    3030                                <label for="key"><?php _e( 'Activation Key:', 'buddypress' ); ?></label>
    31                                 <input type="text" name="key" id="key" value="" />
     31                                <input type="text" name="key" id="key" value="<?php echo esc_attr( bp_get_current_activation_key() ); ?>" />
    3232
    3333                                <p class="submit">
    3434                                        <input type="submit" name="submit" value="<?php esc_attr_e( 'Activate', 'buddypress' ); ?>" />