bp_core_activation_signup_user_notification( string $user, string $user_email, string $key, array $meta )

Notify new users of a successful registration (without blog).


Description Description

See also See also


Top ↑

Parameters Parameters

$user

(string) (Required) The user's login name.

$user_email

(string) (Required) The user's email address.

$key

(string) (Required) The activation key created in wpmu_signup_user().

$meta

(array) (Required) By default, an empty array.


Top ↑

Return Return

(false|string) Returns false to stop original WPMU function from continuing.


Top ↑

Source Source

File: bp-core/bp-core-filters.php

function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) {
	if ( is_admin() ) {

		// If the user is created from the WordPress Add User screen, don't send BuddyPress signup notifications.
		if( in_array( get_current_screen()->id, array( 'user', 'user-network' ) ) ) {
			// If the Super Admin want to skip confirmation email.
			if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) {
				return false;

			// WordPress will manage the signup process.
			} else {
				return $user;
			}

		/*
		 * There can be a case where the user was created without the skip confirmation
		 * And the super admin goes in pending accounts to resend it. In this case, as the
		 * meta['password'] is not set, the activation url must be WordPress one.
		 */
		} elseif ( buddypress()->members->admin->signups_page == get_current_screen()->id ) {
			$is_hashpass_in_meta = maybe_unserialize( $meta );

			if ( empty( $is_hashpass_in_meta['password'] ) ) {
				return $user;
			}
		}
	}

	$user_id = 0;
	$user_object = get_user_by( 'login', $user );
	if ( $user_object ) {
		$user_id = $user_object->ID;
	}

	$salutation = $user;
	if ( bp_is_active( 'xprofile' ) && isset( $meta[ 'field_' . bp_xprofile_fullname_field_id() ] ) ) {
		$salutation = $meta[ 'field_' . bp_xprofile_fullname_field_id() ];
	} elseif ( $user_id ) {
		$salutation = bp_core_get_user_displayname( $user_id );
	}

	$args = array(
		'tokens' => array(
			'activate.url' => esc_url( trailingslashit( bp_get_activation_page() ) . "{$key}/" ),
			'key'          => $key,
			'user.email'   => $user_email,
			'user.id'      => $user_id,
		),
	);
	bp_send_email( 'core-user-registration', array( array( $user_email => $salutation ) ), $args );

	// Return false to stop the original WPMU function from continuing.
	return false;
}


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.