Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/23/2021 05:17:02 PM (6 years ago)
Author:
imath
Message:

Add a new BP Email to welcome new members

Once users activated their account, they are now receiving a welcome email with a link to their profile and a link to reset their password in case they forgot about it since they registered.

Props vapvarun, dcavins

Fixes #8428

File:
1 edited

Legend:

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

    r12797 r12905  
    33073307        ) );
    33083308}
     3309
     3310/**
     3311 * Send welcome email on successful user activation.
     3312 *
     3313 * @since 8.0.0
     3314 *
     3315 * @param int $user_id The new user's ID
     3316 */
     3317function bp_send_welcome_email( $user_id = 0 ) {
     3318        if ( ! $user_id ) {
     3319                return;
     3320        }
     3321
     3322        $profile_url = bp_core_get_user_domain( $user_id );
     3323
     3324        /**
     3325         * Use this filter to add/edit/remove tokens to use for your welcome email.
     3326         *
     3327         * @since 8.0.0
     3328         *
     3329         * @param array $value   An array of BP Email tokens.
     3330         * @param int   $user_id The user ID.
     3331         */
     3332        $welcome_tokens = apply_filters(
     3333                'bp_send_welcome_email_tokens',
     3334                array(
     3335                        'displayname'      => bp_core_get_user_displayname( $user_id ),
     3336                        'profile.url'      => $profile_url,
     3337                        'lostpassword.url' => wp_lostpassword_url( $profile_url ),
     3338                ),
     3339                $user_id
     3340        );
     3341
     3342        bp_send_email( 'core-user-activation', $user_id, array( 'tokens' => $welcome_tokens ) );
     3343}
     3344add_action( 'bp_core_activated_user', 'bp_send_welcome_email', 10, 1 );
Note: See TracChangeset for help on using the changeset viewer.