diff --git src/bp-core/bp-core-filters.php src/bp-core/bp-core-filters.php
index 85a8978d2..2f8a196de 100644
|
|
function bp_core_activation_signup_blog_notification( $domain, $path, $title, $u |
473 | 473 | ), |
474 | 474 | ); |
475 | 475 | |
476 | | $signups = BP_Signup::get( |
477 | | array( |
478 | | 'user_login' => $user, |
479 | | ) |
480 | | ); |
481 | | |
| 476 | $signup = bp_members_get_signup_by( 'activation_key', $key ); |
482 | 477 | $salutation = $user; |
483 | | if ( $signups && bp_is_active( 'xprofile' ) ) { |
484 | | $signup = $signups['signups'][0]; |
| 478 | if ( $signup && bp_is_active( 'xprofile' ) ) { |
485 | 479 | if ( isset( $signup->meta[ 'field_' . bp_xprofile_fullname_field_id() ] ) ) { |
486 | 480 | $salutation = $signup->meta[ 'field_' . bp_xprofile_fullname_field_id() ]; |
487 | 481 | } |
… |
… |
function bp_core_activation_signup_user_notification( $user, $user_email, $key, |
563 | 557 | } |
564 | 558 | add_filter( 'wpmu_signup_user_notification', 'bp_core_activation_signup_user_notification', 1, 4 ); |
565 | 559 | |
| 560 | /** |
| 561 | * Ensure that some meta values are set for new multisite signups. |
| 562 | * |
| 563 | * @since 10.0.0 |
| 564 | * |
| 565 | * @see wpmu_signup_user() for a full description of params. |
| 566 | * |
| 567 | * @param array $meta Signup meta data. Default empty array. |
| 568 | * @return array Signup meta data. |
| 569 | */ |
| 570 | function bp_core_add_meta_to_multisite_signups( $meta ) { |
| 571 | |
| 572 | // Ensure that sent_date and count_sent are set in meta. |
| 573 | if ( ! isset( $meta['sent_date'] ) ) { |
| 574 | $meta['sent_date'] = '0000-00-00 00:00:00'; |
| 575 | } |
| 576 | if ( ! isset( $meta['count_sent'] ) ) { |
| 577 | $meta['count_sent'] = 0; |
| 578 | } |
| 579 | |
| 580 | return $meta; |
| 581 | } |
| 582 | add_filter( 'signup_user_meta', 'bp_core_add_meta_to_multisite_signups' ); |
| 583 | add_filter( 'signup_site_meta', 'bp_core_add_meta_to_multisite_signups' ); |
| 584 | |
566 | 585 | /** |
567 | 586 | * Filter the page title for BuddyPress pages. |
568 | 587 | * |
diff --git src/bp-members/bp-members-functions.php src/bp-members/bp-members-functions.php
index 93fd7cafd..ec4e651ed 100644
|
|
function bp_core_signup_send_validation_email( $user_id, $user_email, $key, $sal |
2388 | 2388 | bp_send_email( 'core-user-registration', $to, $args ); |
2389 | 2389 | |
2390 | 2390 | // Record that the activation email has been sent. |
2391 | | $signups = BP_Signup::get( |
2392 | | array( |
2393 | | 'activation_key' => $key, |
2394 | | ) |
2395 | | ); |
| 2391 | $signup = bp_members_get_signup_by( 'activation_key', $key ); |
2396 | 2392 | |
2397 | | if ( ! empty( $signups['signups'] ) ) { |
2398 | | foreach ( $signups['signups'] as $signup ) { |
2399 | | $meta = array( |
2400 | | 'sent_date' => current_time( 'mysql', true ), |
2401 | | 'count_sent' => $signup->count_sent + 1 |
2402 | | ); |
| 2393 | if ( $signup ) { |
| 2394 | $meta = array( |
| 2395 | 'sent_date' => current_time( 'mysql', true ), |
| 2396 | 'count_sent' => $signup->count_sent + 1 |
| 2397 | ); |
2403 | 2398 | |
2404 | | BP_Signup::update( array( |
2405 | | 'signup_id' => $signup->id, |
2406 | | 'meta' => $meta, |
2407 | | ) ); |
2408 | | } |
| 2399 | BP_Signup::update( array( |
| 2400 | 'signup_id' => $signup->id, |
| 2401 | 'meta' => $meta, |
| 2402 | ) ); |
2409 | 2403 | } |
2410 | 2404 | } |
2411 | 2405 | |
… |
… |
function bp_get_members_invitation_from_request() { |
3694 | 3688 | */ |
3695 | 3689 | return apply_filters( 'bp_get_members_invitation_from_request', $invite ); |
3696 | 3690 | } |
| 3691 | |
| 3692 | /** |
| 3693 | * Get BP_Signup object corresponding to a record in the signups table. |
| 3694 | * |
| 3695 | * @since 10.0.0 |
| 3696 | * |
| 3697 | * @param string $field Which fields to search by. Possible values are |
| 3698 | * activation_key, user_email, id. |
| 3699 | * @param string $value Value to search by. |
| 3700 | * @return bool|BP_Signup $signup Found signup, returns first found |
| 3701 | * if more than one is found. |
| 3702 | */ |
| 3703 | function bp_members_get_signup_by( $field = 'activation_key', $value = '' ) { |
| 3704 | switch ( $field ) { |
| 3705 | case 'activation_key': |
| 3706 | case 'user_email': |
| 3707 | $key = $field; |
| 3708 | break; |
| 3709 | |
| 3710 | case 'id': |
| 3711 | default: |
| 3712 | $key = 'include'; |
| 3713 | break; |
| 3714 | } |
| 3715 | |
| 3716 | $signups = BP_Signup::get( |
| 3717 | array( |
| 3718 | $key => $value, |
| 3719 | ) |
| 3720 | ); |
| 3721 | |
| 3722 | if ( ! empty( $signups['signups'] ) ) { |
| 3723 | $signup = current( $signups['signups'] ); |
| 3724 | } else { |
| 3725 | $signup = false; |
| 3726 | } |
| 3727 | |
| 3728 | return $signup; |
| 3729 | } |
diff --git src/bp-members/classes/class-bp-members-admin.php src/bp-members/classes/class-bp-members-admin.php
index 979847a18..eadd2572a 100644
|
|
class BP_Members_Admin { |
2204 | 2204 | ) ); |
2205 | 2205 | |
2206 | 2206 | $signups = $signups_query['signups']; |
2207 | | $signup_ids = wp_list_pluck( $signups, 'signup_id' ); |
| 2207 | $signup_ids = wp_list_pluck( $signups, 'id' ); |
2208 | 2208 | |
2209 | 2209 | // Set up strings. |
2210 | 2210 | switch ( $action ) { |
diff --git src/bp-members/classes/class-bp-signup.php src/bp-members/classes/class-bp-signup.php
index 9de2af9fe..e48d21da4 100644
|
|
class BP_Signup { |
214 | 214 | $this->date_sent = $signup->registered; |
215 | 215 | } |
216 | 216 | |
| 217 | // How many times has the activation email been sent? |
| 218 | if ( isset( $this->meta['count_sent'] ) ) { |
| 219 | $this->count_sent = absint( $this->meta['count_sent'] ); |
| 220 | } else { |
| 221 | /** |
| 222 | * Meta will not be set if this is a pre-10.0 signup. |
| 223 | * In this case, we assume that the count is 1. |
| 224 | */ |
| 225 | $this->count_sent = 1; |
| 226 | } |
| 227 | |
217 | 228 | /** |
218 | 229 | * Calculate a diff between now & last time |
219 | 230 | * an activation link has been resent. |
… |
… |
class BP_Signup { |
226 | 237 | * Set a boolean to track whether an activation link |
227 | 238 | * was sent in the last day. |
228 | 239 | */ |
229 | | $this->recently_sent = ( $diff < 1 * DAY_IN_SECONDS ); |
| 240 | $this->recently_sent = $this->count_sent && ( $diff < 1 * DAY_IN_SECONDS ); |
230 | 241 | |
231 | | // How many times has the activation email been sent? |
232 | | if ( isset( $this->meta['count_sent'] ) ) { |
233 | | $this->count_sent = absint( $this->meta['count_sent'] ); |
234 | | } else { |
235 | | $this->count_sent = 0; |
236 | | } |
237 | 242 | } |
238 | 243 | |
239 | 244 | /** Static Methods *******************************************************/ |
… |
… |
class BP_Signup { |
814 | 819 | |
815 | 820 | foreach ( $signups as $signup ) { |
816 | 821 | |
817 | | $meta = array( |
818 | | 'sent_date' => current_time( 'mysql', true ), |
819 | | 'count_sent' => $signup->count_sent + 1 |
820 | | ); |
| 822 | $meta = $signup->meta; |
| 823 | $meta['sent_date'] = current_time( 'mysql', true ); |
| 824 | $meta['count_sent'] = $signup->count_sent + 1; |
821 | 825 | |
822 | 826 | // Send activation email. |
823 | 827 | if ( is_multisite() ) { |
824 | | 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 | } |
825 | 834 | } else { |
826 | 835 | |
827 | 836 | // Check user status before sending email. |