Skip to:
Content

BuddyPress.org

Ticket #5789: 5789.03.patch

File 5789.03.patch, 2.2 KB (added by imath, 11 years ago)
  • src/bp-core/bp-core-filters.php

    diff --git src/bp-core/bp-core-filters.php src/bp-core/bp-core-filters.php
    index d02e324..48519f4 100644
    add_filter( 'bp_login_redirect', 'bp_core_login_redirect', 10, 3 ); 
    250250function bp_core_filter_user_welcome_email( $welcome_email ) {
    251251
    252252        // Don't touch the email when a user is registered by the site admin
    253         if ( is_admin() )
     253        if ( is_admin() || is_network_admin() || strpos( bp_get_requested_url(), 'wp-activate.php' ) !== false ) {
    254254                return $welcome_email;
     255        }
    255256
    256257        // Don't touch the email if we don't have a custom registration template
    257         if ( ! bp_has_custom_signup_page() )
     258        if ( ! bp_has_custom_signup_page() ) {
    258259                return $welcome_email;
     260        }
    259261
    260262        // [User Set] Replaces 'PASSWORD' in welcome email; Represents value set by user
    261263        return str_replace( 'PASSWORD', __( '[User Set]', 'buddypress' ), $welcome_email );
    add_filter( 'wpmu_signup_blog_notification', 'bp_core_activation_signup_blog_not 
    351353 */
    352354function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) {
    353355
     356        if ( function_exists( 'get_current_screen' ) ) {
     357                // If the user is created from the WordPress Add User screen, don't send BuddyPress signup notifications
     358                if( in_array( get_current_screen()->id, array( 'user', 'user-network' ) ) ) {
     359                        // If the Super Admin want to skip confirmation email
     360                        if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) {
     361                                return false;
     362
     363                        // WordPress will manage the signup process
     364                        } else {
     365                                return $user;
     366                        }
     367
     368                /**
     369                 * There can be a case where the user was created without the skip confirmation
     370                 * And the super admin goes in pending accounts to resend it. In this case, as the
     371                 * meta['password'] is not set, the activation url must be WordPress one
     372                 */
     373                } else if ( buddypress()->members->admin->signups_page == get_current_screen()->id ) {
     374                        $is_hashpass_in_meta = maybe_unserialize( $meta );
     375
     376                        if ( empty( $is_hashpass_in_meta['password'] ) ) {
     377                                return $user;
     378                        }
     379                }
     380        }
     381
    354382        // Set up activation link
    355383        $activate_url = bp_get_activation_page() . "?key=$key";
    356384        $activate_url = esc_url( $activate_url );