Skip to:
Content

BuddyPress.org

Ticket #5789: 5789.04.patch

File 5789.04.patch, 2.9 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..069014a 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() ) && buddypress()->members->admin->signups_page != get_current_screen()->id ) {
    254254                return $welcome_email;
     255        }
     256
     257        if ( strpos( bp_get_requested_url(), 'wp-activate.php' ) !== false ) {
     258                return $welcome_email;
     259        }
    255260
    256261        // Don't touch the email if we don't have a custom registration template
    257         if ( ! bp_has_custom_signup_page() )
     262        if ( ! bp_has_custom_signup_page() ) {
    258263                return $welcome_email;
     264        }
    259265
    260266        // [User Set] Replaces 'PASSWORD' in welcome email; Represents value set by user
    261267        return str_replace( 'PASSWORD', __( '[User Set]', 'buddypress' ), $welcome_email );
    add_filter( 'update_welcome_user_email', 'bp_core_filter_user_welcome_email' ); 
    279285 */
    280286function bp_core_filter_blog_welcome_email( $welcome_email, $blog_id, $user_id, $password ) {
    281287
    282         // Don't touch the email when a user is registered by the site admin.
    283         if ( is_admin() )
     288        // Don't touch the email when a user is registered by the site admin
     289        if ( ( is_admin() || is_network_admin() ) && buddypress()->members->admin->signups_page != get_current_screen()->id ) {
    284290                return $welcome_email;
     291        }
    285292
    286293        // Don't touch the email if we don't have a custom registration template
    287294        if ( ! bp_has_custom_signup_page() )
    add_filter( 'wpmu_signup_blog_notification', 'bp_core_activation_signup_blog_not 
    351358 */
    352359function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) {
    353360
     361        if ( is_admin() ) {
     362                // If the user is created from the WordPress Add User screen, don't send BuddyPress signup notifications
     363                if( in_array( get_current_screen()->id, array( 'user', 'user-network' ) ) ) {
     364                        // If the Super Admin want to skip confirmation email
     365                        if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) {
     366                                return false;
     367
     368                        // WordPress will manage the signup process
     369                        } else {
     370                                return $user;
     371                        }
     372
     373                /**
     374                 * There can be a case where the user was created without the skip confirmation
     375                 * And the super admin goes in pending accounts to resend it. In this case, as the
     376                 * meta['password'] is not set, the activation url must be WordPress one
     377                 */
     378                } else if ( buddypress()->members->admin->signups_page == get_current_screen()->id ) {
     379                        $is_hashpass_in_meta = maybe_unserialize( $meta );
     380
     381                        if ( empty( $is_hashpass_in_meta['password'] ) ) {
     382                                return $user;
     383                        }
     384                }
     385        }
     386
    354387        // Set up activation link
    355388        $activate_url = bp_get_activation_page() . "?key=$key";
    356389        $activate_url = esc_url( $activate_url );