Skip to:
Content

BuddyPress.org

Changeset 9203


Ignore:
Timestamp:
11/28/2014 08:41:07 PM (12 years ago)
Author:
r-a-y
Message:

Signups: Do not bail if no key is found on the activation screen.

r9109 broke how the activation page is rendered if no key is passed in
the URL. For example, if you go to example.com/activate/ instead of
example.com/activate/?key=XXX or example.com/activate/XXX/.

Anti-props r-a-y.

See #5831.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-screens.php

    r9157 r9203  
    242242    }
    243243
    244     // bail if no key
    245     if ( empty( $key ) ) {
    246         return;
    247     }
    248 
    249     // Activate the signup
    250     $user = apply_filters( 'bp_core_activate_account', bp_core_activate_signup( $key ) );
    251 
    252     // If there were errors, add a message and redirect
    253     if ( ! empty( $user->errors ) ) {
    254         bp_core_add_message( $user->get_error_message(), 'error' );
    255         bp_core_redirect( trailingslashit( bp_get_root_domain() . '/' . $bp->pages->activate->slug ) );
    256     }
    257 
    258     $hashed_key = wp_hash( $key );
    259 
    260     // Check if the avatar folder exists. If it does, move rename it, move
    261     // it and delete the signup avatar dir
    262     if ( file_exists( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key ) ) {
    263         @rename( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key, bp_core_avatar_upload_path() . '/avatars/' . $user );
    264     }
    265 
    266     bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
    267     $bp->activation_complete = true;
     244    // we've got a key; let's attempt to activate the signup
     245    if ( ! empty( $key ) ) {
     246        // Activate the signup
     247        $user = apply_filters( 'bp_core_activate_account', bp_core_activate_signup( $key ) );
     248
     249        // If there were errors, add a message and redirect
     250        if ( ! empty( $user->errors ) ) {
     251            bp_core_add_message( $user->get_error_message(), 'error' );
     252            bp_core_redirect( trailingslashit( bp_get_root_domain() . '/' . $bp->pages->activate->slug ) );
     253        }
     254
     255        $hashed_key = wp_hash( $key );
     256
     257        // Check if the signup avatar folder exists. If it does, move the folder to
     258        // the BP user avatars directory
     259        if ( file_exists( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key ) ) {
     260            @rename( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key, bp_core_avatar_upload_path() . '/avatars/' . $user );
     261        }
     262
     263        bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
     264        $bp->activation_complete = true;
     265    }
    268266
    269267    bp_core_load_template( apply_filters( 'bp_core_template_activate', array( 'activate', 'registration/activate' ) ) );
Note: See TracChangeset for help on using the changeset viewer.