Skip to:
Content

BuddyPress.org

Changeset 13116


Ignore:
Timestamp:
10/05/2021 08:25:49 PM (4 years ago)
Author:
dcavins
Message:

Increment mail sent count in bp_core_signup_send_validation_email().

When the signup validation mail is sent, or re-sent,
increment the BP_Signup's count_sent property.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-functions.php

    r13108 r13116  
    23872387
    23882388    bp_send_email( 'core-user-registration', $to, $args );
     2389
     2390    // Record that the activation email has been sent.
     2391    $signups = BP_Signup::get(
     2392        array(
     2393            'activation_key' => $key,
     2394        )
     2395    );
     2396
     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            );
     2403
     2404            BP_Signup::update( array(
     2405                'signup_id' => $signup->id,
     2406                'meta'      => $meta,
     2407            ) );
     2408        }
     2409    }
    23892410}
    23902411
  • trunk/tests/phpunit/testcases/members/class-bp-signup.php

    r13098 r13116  
    577577
    578578    }
     579
     580    public function test_bp_core_signup_send_validation_email_should_increment_sent_count() {
     581        $activation_key = wp_generate_password( 32, false );
     582        $user_email     = 'accountone@example.com';
     583        $s1             = self::factory()->signup->create( array(
     584            'user_login'     => 'accountone',
     585            'user_email'     => $user_email,
     586            'activation_key' => $activation_key
     587        ) );
     588
     589        $signup = new BP_Signup( $s1 );
     590        $this->assertEquals( 0, $signup->count_sent );
     591
     592        bp_core_signup_send_validation_email( 0, $user_email, $activation_key );
     593
     594        $signup = new BP_Signup( $s1 );
     595        $this->assertEquals( 1, $signup->count_sent );
     596    }
    579597}
Note: See TracChangeset for help on using the changeset viewer.