Ticket #8582: 8582.4.patch
File 8582.4.patch, 15.7 KB (added by , 3 years ago) |
---|
-
src/bp-core/admin/bp-core-admin-settings.php
diff --git src/bp-core/admin/bp-core-admin-settings.php src/bp-core/admin/bp-core-admin-settings.php index 86e456c84..0b249b889 100644
function bp_admin_setting_callback_members_invitations() { 211 211 function bp_admin_setting_callback_membership_requests() { 212 212 ?> 213 213 <input id="bp-enable-membership-requests" name="bp-enable-membership-requests" type="checkbox" value="1" <?php checked( bp_get_membership_requests_required( 'raw' ) ); ?> /> 214 <label for="bp-enable-membership-requests"><?php _e( 'Enable network membership requests. If enabled, an administrator must approve each new network membership.', 'buddypress' ); ?></label>214 <label for="bp-enable-membership-requests"><?php esc_html_e( 'Allow visitors to request a site membership. If enabled, an administrator must approve each new site membership request.', 'buddypress' ); ?></label> 215 215 <?php if ( bp_get_signup_allowed() ) : ?> 216 <p class="description"><?php _e( 'Public registration is currently enabled. If you wish to require approval for new memberships, disable public registration and enable the membership requests feature.', 'buddypress' ); ?></p>216 <p class="description"><?php esc_html_e( 'Public registration is currently enabled. If you wish to require approval for new memberships, disable public registration and enable the membership requests feature.', 'buddypress' ); ?></p> 217 217 <?php endif; ?> 218 218 <?php 219 219 /** -
src/bp-core/bp-core-update.php
diff --git src/bp-core/bp-core-update.php src/bp-core/bp-core-update.php index 533efdb86..d7e0d5b5b 100644
function bp_core_get_8_0_upgrade_email_schema( $emails ) { 708 708 * 10.0.0 update routine. 709 709 * 710 710 * - Explicitly set all signups to count_sent = 1 & sent_date to registered_date 711 * - **Create the new BP Emails**. 711 712 * 712 713 * @since 10.0.0 713 714 */ … … function bp_update_to_10_0() { 716 717 // @TODO: Explicitly set all signups to count_sent = 1 & sent_date to registered_date 717 718 // Is there any way to update that meta in bulk? I think it will have to be one at a time. 718 719 720 // Do we need this upgrade routine? 721 // Could we just assume if count_sent or sent_date defaults to 1 and to the registered_date into the PHP Code? 719 722 } 720 723 721 724 /** -
new file 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 new file mode 100644 index 000000000..7b02da0d1
- + 1 <?php 2 /** 3 * BuddyPress Membership Requests 4 * 5 * @package BuddyPress 6 * @subpackage MembersMembershipRequest 7 * @since 10.0.0 8 */ 9 10 // Exit if accessed directly. 11 defined( 'ABSPATH' ) || exit; 12 13 /** 14 * When a user creates a network membership request, 15 * prevent the sending of the activation email so that 16 * the site admins can send it later. 17 * 18 * @since 10.0.0 19 * 20 * @param bool $send Whether or not to send the activation key. 21 * @param int $user_id User ID to send activation key to. 22 * @param string $user_email User email to send activation key to. 23 * @param string $activation_key Activation key to be sent. 24 * @param array $usermeta Miscellaneous metadata about the user (blog-specific 25 * signup data, xprofile data, etc). 26 * @return bool Whether or not to send the activation key. 27 */ 28 function bp_members_membership_requests_cancel_activation_email( $send, $user_id = 0, $user_email = '', $activation_key = '', $usermeta = array() ) { 29 30 if ( bp_get_membership_requests_required() ) { 31 $details = array( 32 'user_id' => $user_id, 33 'user_email' => $user_email, 34 'activation_key' => $activation_key, 35 'usermeta' => $usermeta, 36 ); 37 38 /** 39 * Allow some membership requests to be approved immediately. 40 * For example, you might want to approve all requests 41 * coming from users with certain email address domains. 42 * If `true` is returned the activation email will be sent to the user. 43 * 44 * @since 10.0.0 45 * 46 * @param bool $send Whether or not this membership request should be approved 47 * immediately and the activation email sent. 48 * Default is `false` meaning that the request should be 49 * manually approved by a site admin. 50 * @param array $details The details of the request. 51 */ 52 $send = apply_filters( 'bp_members_membership_requests_bypass_manual_approval', false, $details ); 53 54 // If the registration process has been interrupted, this is a new membership request. 55 if ( ! $send ) { 56 $signup = bp_members_get_signup_by( 'activation_key', $activation_key ); 57 58 /** 59 * Fires when a site membership request has been created and is pending. 60 * 61 * @since 10.0.0 62 * 63 * @param BP_Signup $signup The signup object that has been created. 64 * @param array $details The details of the request. 65 */ 66 do_action( 'bp_members_membership_request_submitted', $signup, $details ); 67 } 68 } 69 70 return $send; 71 } 72 add_filter( 'bp_core_signup_send_activation_key', 'bp_members_membership_requests_cancel_activation_email', 10, 5 ); 73 74 75 /** 76 * Notify site admins about a new membership request. 77 * 78 * @since 10.0.0 79 * 80 * @param BP_Signup $signup The signup object that has been created. 81 */ 82 function bp_members_membership_requests_notify_site_admins( $signup ) { 83 // Why not just using get_option( 'admin_email' ) ? 84 $admin_ids = get_users( 85 array( 86 'fields' => 'ids', 87 'role' => 'administrator', 88 ) 89 ); 90 91 foreach ( $admin_ids as $admin_id ) { 92 // Trigger a BuddyPress Notification. 93 if ( bp_is_active( 'notifications' ) ) { 94 bp_notifications_add_notification( 95 array( 96 'user_id' => $admin_id, 97 'item_id' => $signup->signup_id, 98 'component_name' => buddypress()->members->id, 99 'component_action' => 'membership_request_submitted', 100 'date_notified' => bp_core_current_time(), 101 'is_new' => 1, 102 ) 103 ); 104 } 105 106 // Bail if member opted out of receiving this email. 107 if ( 'no' === bp_get_user_meta( $admin_id, 'notification_members_membership_request', true ) ) { 108 return; 109 } 110 111 $unsubscribe_args = array( 112 'user_id' => $admin_id, 113 'notification_type' => 'members-membership-request', 114 ); 115 116 $manage_url = add_query_arg( 117 array( 118 'mod_req' => 1, 119 'page' => 'bp-signups', 120 'signup_id' => $signup->signup_id, 121 'action' => 'resend', 122 ), 123 bp_get_admin_url( 'users.php' ) 124 ); 125 126 $args = array( 127 'tokens' => array( 128 'admin.id' => $admin_id, 129 'manage.url' => esc_url_raw( $manage_url ), 130 'requesting-user.user_login' => esc_html( $signup->user_login ), 131 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ), 132 ), 133 ); 134 135 bp_send_email( 'members-membership-request', (int) $admin_id, $args ); 136 } 137 } 138 add_action( 'bp_members_membership_request_submitted', 'bp_members_membership_requests_notify_site_admins' ); 139 140 /** 141 * Add "Request Membership" link to Widget login form. 142 * 143 * @since 10.0.0 144 * 145 * @return string $retval the HTML for the request membership link. 146 */ 147 function bp_members_membership_requests_add_link_to_widget_login_form() { 148 if ( ! bp_get_membership_requests_required() ) { 149 return; 150 } 151 ?> 152 <span class="bp-login-widget-request-membership-link"> 153 <a href="<?php echo esc_url( bp_get_signup_page() ); ?>"><?php esc_html_e( 'Request Membership', 'buddypress' ); ?></a> 154 </span> 155 <?php 156 } 157 add_action( 'bp_login_widget_form', 'bp_members_membership_requests_add_link_to_widget_login_form' ); 158 159 /** 160 * In the Nouveau template pack, when membership requests are required, 161 * change registration form submit button label to "Submit Request". 162 * 163 * @since 10.0.0 164 * 165 * @return string $retval the HTML for the request membership link. 166 */ 167 function bp_members_membership_requests_filter_complete_signup_button( $buttons ) { 168 if ( bp_get_membership_requests_required() ) { 169 $buttons['register']['attributes']['value'] = __( 'Submit Request', 'buddypress' ); 170 } 171 172 return $buttons; 173 } 174 add_filter( 'bp_nouveau_get_submit_button', 'bp_members_membership_requests_filter_complete_signup_button' ); -
src/bp-members/bp-members-notifications.php
diff --git src/bp-members/bp-members-notifications.php src/bp-members/bp-members-notifications.php index d63126341..ab63dd8cd 100644
function members_screen_notification_settings() { 254 254 ?> 255 255 <tr id="members-notification-settings-invitation_accepted"> 256 256 <td></td> 257 <td><?php _ex( 'Someone accepts your membership invitation', 'Member settings on notification settings page', 'buddypress' )?></td>257 <td><?php echo esc_html_x( 'Someone accepts your membership invitation', 'Member settings on notification settings page', 'buddypress' ); ?></td> 258 258 <td class="yes"><input type="radio" name="notifications[notification_members_invitation_accepted]" id="notification-members-invitation-accepted-yes" value="yes" <?php checked( $allow_acceptance_emails, 'yes', true ) ?>/><label for="notification-members-invitation-accepted-yes" class="bp-screen-reader-text"><?php 259 259 /* translators: accessibility text */ 260 _e( 'Yes, send email', 'buddypress' );260 esc_html_e( 'Yes, send email', 'buddypress' ); 261 261 ?></label></td> 262 262 <td class="no"><input type="radio" name="notifications[notification_members_invitation_accepted]" id="notification-members-invitation-accepted-no" value="no" <?php checked( $allow_acceptance_emails, 'no', true ) ?>/><label for="notification-members-invitation-accepted-no" class="bp-screen-reader-text"><?php 263 263 /* translators: accessibility text */ 264 _e( 'No, do not send email', 'buddypress' );264 esc_html_e( 'No, do not send email', 'buddypress' ); 265 265 ?></label></td> 266 266 </tr> 267 267 <?php … … function members_screen_notification_settings() { 274 274 ?> 275 275 <tr id="members-notification-settings-submitted_membership_request"> 276 276 <td></td> 277 <td><?php _ex( 'Someone has requested site membership', 'Member settings on notification settings page', 'buddypress' ) ?></td>277 <td><?php echo esc_html_x( 'Someone has requested site membership', 'Member settings on notification settings page', 'buddypress' ) ?></td> 278 278 <td class="yes"><input type="radio" name="notifications[notification_members_membership_request]" id="notification-members-submitted_membership_request-yes" value="yes" <?php checked( $allow_request_emails, 'yes', true ) ?>/><label for="notification-members-submitted_membership_request-yes" class="bp-screen-reader-text"><?php 279 279 /* translators: accessibility text */ 280 _e( 'Yes, send email', 'buddypress' );280 esc_html_e( 'Yes, send email', 'buddypress' ); 281 281 ?></label></td> 282 282 <td class="no"><input type="radio" name="notifications[notification_members_membership_request]" id="notification-members-submitted_membership_request-no" value="no" <?php checked( $allow_request_emails, 'no', true ) ?>/><label for="notification-members-submitted_membership_request-no" class="bp-screen-reader-text"><?php 283 283 /* translators: accessibility text */ 284 _e( 'No, do not send email', 'buddypress' );284 esc_html_e( 'No, do not send email', 'buddypress' ); 285 285 ?></label></td> 286 286 </tr> 287 287 <?php -
src/bp-members/classes/class-bp-members-admin.php
diff --git src/bp-members/classes/class-bp-members-admin.php src/bp-members/classes/class-bp-members-admin.php index 08eb51dbf..ba80808d7 100644
class BP_Members_Admin { 2230 2230 2231 2231 if ( bp_get_membership_requests_required() ) { 2232 2232 $header_text = __( 'Approve Membership Requests', 'buddypress' ); 2233 if ( 1 == count( $signup_ids ) ) {2233 if ( 1 === count( $signup_ids ) ) { 2234 2234 $helper_text = __( 'You are about to send an approval email to the following user:', 'buddypress' ); 2235 2235 } else { 2236 2236 $helper_text = __( 'You are about to send approval emails to the following users:', 'buddypress' ); 2237 2237 } 2238 2238 } else { 2239 2239 $header_text = __( 'Resend Activation Emails', 'buddypress' ); 2240 if ( 1 == count( $signup_ids ) ) {2240 if ( 1 === count( $signup_ids ) ) { 2241 2241 $helper_text = __( 'You are about to resend an activation email to the following account:', 'buddypress' ); 2242 2242 } else { 2243 2243 $helper_text = __( 'You are about to resend an activation email to the following accounts:', 'buddypress' ); -
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 ddf725356..8e7e79eb0 100644
class BP_Members_Component extends BP_Component { 67 67 'widgets', 68 68 'cache', 69 69 'invitations', 70 'membership-requests',71 70 'notifications', 72 71 ); 73 72 … … class BP_Members_Component extends BP_Component { 75 74 $includes[] = 'activity'; 76 75 } 77 76 77 if ( bp_is_active( 'members', 'invitations' ) && (bool) bp_get_option( 'bp-enable-membership-requests' ) ) { 78 $includes[] = 'membership-requests'; 79 } 80 78 81 // Include these only if in admin. 79 82 if ( is_admin() ) { 80 83 $includes[] = 'admin'; -
src/bp-members/classes/class-bp-members-list-table.php
diff --git src/bp-members/classes/class-bp-members-list-table.php src/bp-members/classes/class-bp-members-list-table.php index ddf4b6d02..feb9b4668 100644
class BP_Members_List_Table extends WP_Users_List_Table { 470 470 <h2><?php echo esc_html__( 'Extended Profile Information', 'buddypress' ); ?></h2> 471 471 472 472 <table class="signup-profile-data-drawer wp-list-table widefat fixed striped"> 473 <?php foreach ( $profile_field_ids as $pid => $noop ) :473 <?php if ( 1 <= count( $profile_field_ids ) ): foreach ( $profile_field_ids as $pid => $noop ) : 474 474 $field_value = isset( $signup_object->meta[ "field_{$pid}" ] ) ? $signup_object->meta[ "field_{$pid}" ] : ''; ?> 475 475 <tr> 476 476 <td class="column-fields"><?php echo esc_html( $fdata[ $pid ] ); ?></td> 477 477 <td><?php echo $this->format_xprofile_field_for_display( $field_value ); ?></td> 478 478 </tr> 479 480 <?php endforeach; ?> 479 <?php endforeach;else: ?> 480 <tr> 481 <td><?php esc_html_e( 'There are no additional information to display.', 'buddypress' ); ?></td> 482 </tr> 483 <?php endif; ?> 481 484 </table> 482 485 </div> 483 486 <?php -
src/bp-members/classes/class-bp-members-ms-list-table.php
diff --git src/bp-members/classes/class-bp-members-ms-list-table.php src/bp-members/classes/class-bp-members-ms-list-table.php index 557e58952..918748378 100644
class BP_Members_MS_List_Table extends WP_MS_Users_List_Table { 472 472 <h2><?php echo esc_html__( 'Extended Profile Information', 'buddypress' ); ?></h2> 473 473 474 474 <table class="signup-profile-data-drawer wp-list-table widefat fixed striped"> 475 <?php foreach ( $profile_field_ids as $pid => $noop ) :475 <?php if ( 1 <= count( $profile_field_ids ) ): foreach ( $profile_field_ids as $pid => $noop ) : 476 476 $field_value = isset( $signup_object->meta[ "field_{$pid}" ] ) ? $signup_object->meta[ "field_{$pid}" ] : ''; ?> 477 477 <tr> 478 478 <td class="column-fields"><?php echo esc_html( $fdata[ $pid ] ); ?></td> 479 479 <td><?php echo $this->format_xprofile_field_for_display( $field_value ); ?></td> 480 480 </tr> 481 482 <?php endforeach; ?> 481 <?php endforeach;else: ?> 482 <tr> 483 <td><?php esc_html_e( 'There are no additional information to display.', 'buddypress' ); ?></td> 484 </tr> 485 <?php endif; ?> 483 486 </table> 484 487 </div> 485 488 <?php