Skip to:
Content

BuddyPress.org

Ticket #8582: 8582.10-just-diff.patch

File 8582.10-just-diff.patch, 9.7 KB (added by dcavins, 3 years ago)

Just the changes from the .9 patch.

  • src/bp-core/bp-core-filters.php

    diff --git src/bp-core/bp-core-filters.php src/bp-core/bp-core-filters.php
    index b41c54410..622c2bbce 100644
    add_filter( 'update_welcome_email', 'bp_core_filter_blog_welcome_email', 10, 4 ) 
    461461 * @return bool              Returns false to stop original WPMU function from continuing.
    462462 */
    463463function bp_core_activation_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key ) {
     464        $is_signup_resend = false;
     465        if ( is_admin() && buddypress()->members->admin->signups_page == get_current_screen()->id ) {
     466                // The admin is just approving/sending/resending the verification email.
     467                $is_signup_resend = true;
     468        }
     469
    464470        $args = array(
    465471                'tokens' => array(
    466472                        'activate-site.url' => esc_url( bp_get_activation_page() . '?key=' . urlencode( $key ) ),
    function bp_core_activation_signup_blog_notification( $domain, $path, $title, $u 
    486492         *
    487493         * @since 10.0.0
    488494         *
    489          * @param string $user       The user's login name.
    490          * @param string $user_email The user's email address.
    491          * @param string $key        The activation key created in wpmu_signup_blog().
    492          * @param string $domain     The new blog domain.
    493          * @param string $path       The new blog path.
    494          * @param string $title      The site title.
     495         * @param string $user             The user's login name.
     496         * @param string $user_email       The user's email address.
     497         * @param string $key              The activation key created in wpmu_signup_blog().
     498         * @param bool   $is_signup_resend Is the site admin sending this email?
     499         * @param string $domain           The new blog domain.
     500         * @param string $path             The new blog path.
     501         * @param string $title            The site title.
    495502         */
    496         if ( apply_filters( 'bp_core_signup_send_activation_key_multisite_blog', true, $user, $user_email, $key, $domain, $path, $title ) ) {
     503        if ( apply_filters( 'bp_core_signup_send_activation_key_multisite_blog', true, $user, $user_email, $key, $is_signup_resend, $domain, $path, $title ) ) {
    497504
    498505                bp_send_email( 'core-user-registration-with-blog', array( array( $user_email => $salutation ) ), $args );
    499506
    add_filter( 'wpmu_signup_blog_notification', 'bp_core_activation_signup_blog_not 
    518525 * @return false|string Returns false to stop original WPMU function from continuing.
    519526 */
    520527function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) {
     528        $is_signup_resend = false;
    521529        if ( is_admin() ) {
    522530
    523531                // If the user is created from the WordPress Add User screen, don't send BuddyPress signup notifications.
    function bp_core_activation_signup_user_notification( $user, $user_email, $key, 
    531539                                return $user;
    532540                        }
    533541
    534                 /*
    535                  * There can be a case where the user was created without the skip confirmation
    536                  * And the super admin goes in pending accounts to resend it. In this case, as the
    537                  * meta['password'] is not set, the activation url must be WordPress one.
    538                  */
     542                // The site admin is approving/resending from the "manage signups" screen.
    539543                } elseif ( buddypress()->members->admin->signups_page == get_current_screen()->id ) {
     544                        /*
     545                         * There can be a case where the user was created without the skip confirmation
     546                         * And the super admin goes in pending accounts to resend it. In this case, as the
     547                         * meta['password'] is not set, the activation url must be WordPress one.
     548                         */
    540549                        $is_hashpass_in_meta = maybe_unserialize( $meta );
    541550
    542551                        if ( empty( $is_hashpass_in_meta['password'] ) ) {
    543552                                return $user;
    544553                        }
     554
     555                        // Or the admin is just approving/sending/resending the verification email.
     556                        $is_signup_resend = true;
    545557                }
    546558        }
    547559
    function bp_core_activation_signup_user_notification( $user, $user_email, $key, 
    572584         *
    573585         * @since 10.0.0
    574586         *
    575          * @param string $user       The user's login name.
    576          * @param string $user_email The user's email address.
    577          * @param string $key        The activation key created in wpmu_signup_blog().
     587         * @param string $user             The user's login name.
     588         * @param string $user_email       The user's email address.
     589         * @param string $key              The activation key created in wpmu_signup_blog().
     590         * @param bool   $is_signup_resend Is the site admin sending this email?
    578591         */
    579         if ( apply_filters( 'bp_core_signup_send_activation_key_multisite', true, $user, $user_email, $key ) ) {
     592        if ( apply_filters( 'bp_core_signup_send_activation_key_multisite', true, $user, $user_email, $key, $is_signup_resend ) ) {
    580593
    581594                bp_send_email( 'core-user-registration', array( array( $user_email => $salutation ) ), $args );
    582595
    583596        }
    584597
    585 
    586598        // Return false to stop the original WPMU function from continuing.
    587599        return false;
    588600}
    function bp_core_add_meta_to_multisite_signups( $meta ) { 
    611623        return $meta;
    612624}
    613625add_filter( 'signup_user_meta', 'bp_core_add_meta_to_multisite_signups' );
     626add_filter( 'signup_site_meta', 'bp_core_add_meta_to_multisite_signups' );
    614627
    615628/**
    616629 * Filter the page title for BuddyPress pages.
  • src/bp-members/bp-members-membership-requests.php

    diff --git src/bp-members/bp-members-membership-requests.php src/bp-members/bp-members-membership-requests.php
    index a55f71726..b0ad8d223 100644
    add_filter( 'bp_core_signup_send_activation_key', 'bp_members_membership_request 
    7676 *
    7777 * @since 10.0.0
    7878 *
    79  * @param bool   $send           Whether or not to send the activation key.
    80  * @param string $user_login     User login name.
    81  * @param string $user_email     User email address.
    82  * @param string $activation_key Activation key created in wpmu_signup_user().
     79 * @param bool   $send             Whether or not to send the activation key.
     80 * @param string $user_login       User login name.
     81 * @param string $user_email       User email address.
     82 * @param string $activation_key   Activation key created in wpmu_signup_user().
     83 * @param bool   $is_signup_resend Is the site admin sending this email?
    8384 * @return bool Whether or not to send the activation key.
    8485 */
    85 function bp_members_membership_requests_cancel_activation_email_multisite( $send = true, $user_login = '', $user_email = '', $activation_key = '' ) {
     86function bp_members_membership_requests_cancel_activation_email_multisite( $send = true, $user_login = '', $user_email = '', $activation_key = '', $is_signup_resend = false ) {
    8687
    8788        $details = array(
    88                 'user_login'     => $user_login,
    89                 'user_email'     => $user_email,
    90                 'activation_key' => $activation_key,
     89                'user_login'       => $user_login,
     90                'user_email'       => $user_email,
     91                'activation_key'   => $activation_key,
     92                'is_signup_resend' => $is_signup_resend,
    9193        );
    9294
     95        // Allow the site admin to send/resend approval emails.
     96        if ( $is_signup_resend ) {
     97                $to_send = true;
     98        } else {
     99                $to_send = false;
     100        }
     101
    93102        /**
    94103         * Allow some membership requests to be approved immediately.
    95104         * For example, you might want to approve all requests
    function bp_members_membership_requests_cancel_activation_email_multisite( $send 
    98107         *
    99108         * @since 10.0.0
    100109         *
    101          * @param bool  $send    Whether or not this membership request should be approved
     110         * @param bool  $to_send Whether or not this membership request should be approved
    102111         *                       immediately and the activation email sent.
    103112         *                       Default is `false` meaning that the request should be
    104113         *                       manually approved by a site admin.
    105114         * @param array $details The details of the request.
    106115         */
    107         $send = apply_filters( 'bp_members_membership_requests_bypass_manual_approval_multisite', false, $details );
     116        $send = apply_filters( 'bp_members_membership_requests_bypass_manual_approval_multisite', $to_send, $details );
    108117
    109118        // If the registration process has been interrupted, this is a new membership request.
    110119        if ( ! $send ) {
    function bp_members_membership_requests_cancel_activation_email_multisite( $send 
    123132
    124133        return $send;
    125134}
    126 add_filter( 'bp_core_signup_send_activation_key_multisite', 'bp_members_membership_requests_cancel_activation_email_multisite', 10, 4 );
    127 add_filter( 'bp_core_signup_send_activation_key_multisite_blog', 'bp_members_membership_requests_cancel_activation_email_multisite', 10, 4 );
     135add_filter( 'bp_core_signup_send_activation_key_multisite', 'bp_members_membership_requests_cancel_activation_email_multisite', 10, 5 );
     136add_filter( 'bp_core_signup_send_activation_key_multisite_blog', 'bp_members_membership_requests_cancel_activation_email_multisite', 10, 5 );
    128137
    129138/**
    130139 * Notifications
  • src/bp-members/classes/class-bp-signup.php

    diff --git src/bp-members/classes/class-bp-signup.php src/bp-members/classes/class-bp-signup.php
    index 76b2022d0..e48d21da4 100644
    class BP_Signup { 
    819819
    820820                foreach ( $signups as $signup ) {
    821821
    822                         $meta = array(
    823                                 'sent_date'  => current_time( 'mysql', true ),
    824                                 'count_sent' => $signup->count_sent + 1
    825                         );
     822                        $meta               = $signup->meta;
     823                        $meta['sent_date']  = current_time( 'mysql', true );
     824                        $meta['count_sent'] = $signup->count_sent + 1;
    826825
    827826                        // Send activation email.
    828827                        if ( is_multisite() ) {
    829                                 wpmu_signup_user_notification( $signup->user_login, $signup->user_email, $signup->activation_key, serialize( $meta ) );
     828                                // Should we send the user or blog activation email?
     829                                if ( ! empty( $signup->domain ) || ! empty( $signup->path ) ) {
     830                                        wpmu_signup_blog_notification( $signup->domain, $signup->path, $signup->title, $signup->user_login, $signup->user_email, $signup->activation_key, $meta );
     831                                } else {
     832                                        wpmu_signup_user_notification( $signup->user_login, $signup->user_email, $signup->activation_key, $meta );
     833                                }
    830834                        } else {
    831835
    832836                                // Check user status before sending email.