Skip to:
Content

BuddyPress.org

Ticket #8582: 8582.9-just-diff.patch

File 8582.9-just-diff.patch, 11.6 KB (added by dcavins, 22 months ago)

Just the changes made after imath's .8 patch. It contains the necessary changes for multisite setups, so that the activation email is interrupted like it is on single site setups

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

    diff --git src/bp-core/bp-core-filters.php src/bp-core/bp-core-filters.php
    index 85a8978d2..b41c54410 100644
    function bp_core_activation_signup_blog_notification( $domain, $path, $title, $u 
    473473                ),
    474474        );
    475475
    476         $signups = BP_Signup::get(
    477                 array(
    478                         'user_login' => $user,
    479                 )
    480         );
    481 
     476        $signup     = bp_members_get_signup_by( 'activation_key', $key );
    482477        $salutation = $user;
    483         if ( $signups && bp_is_active( 'xprofile' ) ) {
    484                 $signup = $signups['signups'][0];
     478        if ( $signup && bp_is_active( 'xprofile' ) ) {
    485479                if ( isset( $signup->meta[ 'field_' . bp_xprofile_fullname_field_id() ] ) ) {
    486480                        $salutation = $signup->meta[ 'field_' . bp_xprofile_fullname_field_id() ];
    487481                }
    488482        }
    489483
    490         bp_send_email( 'core-user-registration-with-blog', array( array( $user_email => $salutation ) ), $args );
     484        /**
     485         * Filters if BuddyPress should send an activation key for a new multisite signup.
     486         *
     487         * @since 10.0.0
     488         *
     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         */
     496        if ( apply_filters( 'bp_core_signup_send_activation_key_multisite_blog', true, $user, $user_email, $key, $domain, $path, $title ) ) {
     497
     498                bp_send_email( 'core-user-registration-with-blog', array( array( $user_email => $salutation ) ), $args );
     499
     500        }
    491501
    492502        // Return false to stop the original WPMU function from continuing.
    493503        return false;
    function bp_core_activation_signup_user_notification( $user, $user_email, $key, 
    556566                        'user.id'      => $user_id,
    557567                ),
    558568        );
    559         bp_send_email( 'core-user-registration', array( array( $user_email => $salutation ) ), $args );
     569
     570        /**
     571         * Filters if BuddyPress should send an activation key for a new multisite signup.
     572         *
     573         * @since 10.0.0
     574         *
     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().
     578         */
     579        if ( apply_filters( 'bp_core_signup_send_activation_key_multisite', true, $user, $user_email, $key ) ) {
     580
     581                bp_send_email( 'core-user-registration', array( array( $user_email => $salutation ) ), $args );
     582
     583        }
     584
    560585
    561586        // Return false to stop the original WPMU function from continuing.
    562587        return false;
    563588}
    564589add_filter( 'wpmu_signup_user_notification', 'bp_core_activation_signup_user_notification', 1, 4 );
    565590
     591/**
     592 * Ensure that some meta values are set for new multisite signups.
     593 *
     594 * @since 10.0.0
     595 *
     596 * @see wpmu_signup_user() for a full description of params.
     597 *
     598 * @param array $meta Signup meta data. Default empty array.
     599 * @return array Signup meta data.
     600 */
     601function bp_core_add_meta_to_multisite_signups( $meta ) {
     602
     603        // Ensure that sent_date and count_sent are set in meta.
     604        if ( ! isset( $meta['sent_date'] ) ) {
     605                $meta['sent_date'] = '0000-00-00 00:00:00';
     606        }
     607        if ( ! isset( $meta['count_sent'] ) ) {
     608                $meta['count_sent'] = 0;
     609        }
     610
     611        return $meta;
     612}
     613add_filter( 'signup_user_meta', 'bp_core_add_meta_to_multisite_signups' );
     614
    566615/**
    567616 * Filter the page title for BuddyPress pages.
    568617 *
  • src/bp-members/bp-members-functions.php

    diff --git src/bp-members/bp-members-functions.php src/bp-members/bp-members-functions.php
    index 9a389cdda..e61bdf632 100644
    function bp_core_signup_disable_inactive( $user = null, $username = '', $passwor 
    24512451        if ( bp_get_membership_requests_required() ) {
    24522452                $error_message = sprintf(
    24532453                        '<strong>%1$s</strong> %2$s',
    2454                         esc_html_x( 'Error:', 'Warning used into the WP Login screen', 'buddypress' ),
    2455                         esc_html_x( 'Your membership request has not yet been approved.', 'Error message used into the WP Login screen', 'buddypress' )
     2454                        esc_html_x( 'Error:', 'Warning displayed on the WP Login screen', 'buddypress' ),
     2455                        esc_html_x( 'Your membership request has not yet been approved.', 'Error message displayed on the WP Login screen', 'buddypress' )
    24562456                );
    24572457        } else {
    24582458                // Set up the feedback message.
    function bp_core_signup_disable_inactive( $user = null, $username = '', $passwor 
    24702470
    24712471                $error_message = sprintf(
    24722472                        '<strong>%1$s</strong> %2$s<br /><br />%3$s',
    2473                         esc_html_x( 'Error:', 'Warning used into the WP Login screen', 'buddypress' ),
    2474                         esc_html_x( 'Your account has not been activated. Check your email for the activation link.', 'Error message used into the WP Login screen', 'buddypress' ),
     2473                        esc_html_x( 'Error:', 'Warning displayed on the WP Login screen', 'buddypress' ),
     2474                        esc_html_x( 'Your account has not been activated. Check your email for the activation link.', 'Error message displayed on the WP Login screen', 'buddypress' ),
    24752475                        sprintf(
    24762476                                /* translators: %s: the link to resend the activation email. */
    24772477                                esc_html_x( 'If you have not received an email yet, %s.', 'WP Login screen message', 'buddypress' ),
  • src/bp-members/bp-members-invitations.php

    diff --git src/bp-members/bp-members-invitations.php src/bp-members/bp-members-invitations.php
    index 1924710cc..2fadc0e94 100644
    function bp_members_invitations_maybe_bypass_request_approval( $send, $details ) 
    221221        return $send;
    222222}
    223223add_filter( 'bp_members_membership_requests_bypass_manual_approval', 'bp_members_invitations_maybe_bypass_request_approval', 10, 2 );
     224add_filter( 'bp_members_membership_requests_bypass_manual_approval_multisite', 'bp_members_invitations_maybe_bypass_request_approval', 10, 2 );
  • 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 e1ab537ad..a55f71726 100644
     
    1111defined( 'ABSPATH' ) || exit;
    1212
    1313/**
    14  * When a user creates a membership request,
     14 * Single site: When a user creates a membership request,
    1515 * prevent the sending of the activation email so that
    1616 * the site admins can send it manually.
    1717 *
    function bp_members_membership_requests_cancel_activation_email( $send, $user_id 
    6969}
    7070add_filter( 'bp_core_signup_send_activation_key', 'bp_members_membership_requests_cancel_activation_email', 10, 5 );
    7171
     72/**
     73 * WP Multisite: When a user creates a membership request,
     74 * prevent the sending of the activation email so that
     75 * the site admins can send it manually.
     76 *
     77 * @since 10.0.0
     78 *
     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 * @return bool Whether or not to send the activation key.
     84 */
     85function bp_members_membership_requests_cancel_activation_email_multisite( $send = true, $user_login = '', $user_email = '', $activation_key = '' ) {
     86
     87        $details = array(
     88                'user_login'     => $user_login,
     89                'user_email'     => $user_email,
     90                'activation_key' => $activation_key,
     91        );
     92
     93        /**
     94         * Allow some membership requests to be approved immediately.
     95         * For example, you might want to approve all requests
     96         * coming from users with certain email address domains.
     97         * If `true` is returned the activation email will be sent to the user.
     98         *
     99         * @since 10.0.0
     100         *
     101         * @param bool  $send    Whether or not this membership request should be approved
     102         *                       immediately and the activation email sent.
     103         *                       Default is `false` meaning that the request should be
     104         *                       manually approved by a site admin.
     105         * @param array $details The details of the request.
     106         */
     107        $send = apply_filters( 'bp_members_membership_requests_bypass_manual_approval_multisite', false, $details );
     108
     109        // If the registration process has been interrupted, this is a new membership request.
     110        if ( ! $send ) {
     111                $signup = bp_members_get_signup_by( 'activation_key', $activation_key );
     112
     113                /**
     114                 * Fires when a site membership request has been created and is pending.
     115                 *
     116                 * @since 10.0.0
     117                 *
     118                 * @param BP_Signup $signup  The signup object that has been created.
     119                 * @param array     $details The details of the request.
     120                 */
     121                do_action( 'bp_members_membership_request_submitted', $signup, $details );
     122        }
     123
     124        return $send;
     125}
     126add_filter( 'bp_core_signup_send_activation_key_multisite', 'bp_members_membership_requests_cancel_activation_email_multisite', 10, 4 );
     127add_filter( 'bp_core_signup_send_activation_key_multisite_blog', 'bp_members_membership_requests_cancel_activation_email_multisite', 10, 4 );
    72128
    73129/**
    74130 * Notifications
    add_filter( 'bp_core_signup_send_activation_key', 'bp_members_membership_request 
    83139 */
    84140function bp_members_membership_requests_notify_site_admins( $signup ) {
    85141
     142        if ( ! isset( $signup->signup_id ) ) {
     143                return;
     144        }
     145
    86146        // Notify all site admins so the request can be handled.
    87147        $admin_ids = get_users(
    88148                array(
  • src/bp-members/bp-members-notifications.php

    diff --git src/bp-members/bp-members-notifications.php src/bp-members/bp-members-notifications.php
    index b84a0938a..08285bcb6 100644
    add_action( 'bp_screens', 'bp_members_mark_read_accepted_invitation_notification 
    205205 * @since 10.0.0
    206206 */
    207207function bp_members_mark_read_submitted_membership_request_notification() {
    208         if ( ! wp_doing_ajax() && 'users_page_bp-signups' === get_current_screen()->base && ! empty( $_GET['mod_req'] ) && ! empty( $_GET['signup_id'] ) ) {
     208
     209        $signup_screens = array( 'users_page_bp-signups', 'users_page_bp-signups-network' );
     210        if ( ! wp_doing_ajax() && in_array( get_current_screen()->base, $signup_screens, true ) && ! empty( $_GET['mod_req'] ) && ! empty( $_GET['signup_id'] ) ) {
    209211                // Mark all notifications about this request as read.
    210212                BP_Notifications_Notification::update(
    211213                        array(
  • src/bp-members/classes/class-bp-members-component.php

    diff --git src/bp-members/classes/class-bp-members-component.php src/bp-members/classes/class-bp-members-component.php
    index dca58193e..17c82b95f 100644
    class BP_Members_Component extends BP_Component { 
    7474                        $includes[] = 'activity';
    7575                }
    7676
    77                 if ( bp_is_active( 'members', 'membership_requests' ) && (bool) bp_get_option( 'bp-enable-membership-requests' ) ) {
     77                /**
     78                 * Duplicate bp_get_membership_requests_required() and
     79                 * bp_get_signup_allowed() logic here,
     80                 * because those functions are not available yet.
     81                 * The `bp_get_signup_allowed` filter is documented in
     82                 * bp-members/bp-members-template.php.
     83                 */
     84                $signup_allowed = apply_filters( 'bp_get_signup_allowed', (bool) bp_get_option( 'users_can_register' ) );
     85                $membership_requests_enabled = (bool) bp_get_option( 'bp-enable-membership-requests' );
     86                if ( bp_is_active( 'members', 'membership_requests' ) && ! $signup_allowed && $membership_requests_enabled ) {
    7887                        $includes[] = 'membership-requests';
    7988                }
    8089
  • src/bp-members/screens/register.php

    diff --git src/bp-members/screens/register.php src/bp-members/screens/register.php
    index 40dd280dc..2f3f1da1b 100644
    function bp_core_screen_signup() { 
    199199                        // No errors! Let's register those deets.
    200200                        $active_signup = bp_core_get_root_option( 'registration' );
    201201
    202                         if ( 'none' != $active_signup ) {
     202                        if ( 'none' != $active_signup || $requests_enabled ) {
    203203
    204204                                // Make sure the extended profiles module is enabled.
    205205                                if ( bp_is_active( 'xprofile' ) ) {