Dev Resources

  • Home
  • Reference
  • BuddyX Theme
  • Functions
  • Hooks
  • Classes
Filter by type:
Search
Browse: Home / Reference / Classes / BP_Signup / BP_Signup::resend()

BP_Signup::resend( array $signup_ids = array() )

Resend an activation email.

Contents

  • Description
    • Parameters
    • Return
    • Source
    • Changelog
  • User Contributed Notes

Description #Description


Parameters #Parameters

$signup_ids

(Optional) Single ID or list of IDs to resend.

Default value: array()


Top ↑

Return #Return

(array)


Top ↑

Source #Source

File: bp-members/classes/class-bp-signup.php

	public static function resend( $signup_ids = array() ) {
		if ( empty( $signup_ids ) || ! is_array( $signup_ids ) ) {
			return false;
		}

		$to_resend = self::get( array(
			'include' => $signup_ids,
		) );

		if ( ! $signups = $to_resend['signups'] ) {
			return false;
		}

		$result = array();

		/**
		 * Fires before activation emails are resent.
		 *
		 * @since 2.0.0
		 *
		 * @param array $signup_ids Array of IDs to resend activation emails to.
		 */
		do_action( 'bp_core_signup_before_resend', $signup_ids );

		foreach ( $signups as $signup ) {

			$meta               = $signup->meta;
			$meta['sent_date']  = current_time( 'mysql', true );
			$meta['count_sent'] = $signup->count_sent + 1;

			// Send activation email.
			if ( is_multisite() ) {
				wpmu_signup_user_notification( $signup->user_login, $signup->user_email, $signup->activation_key, serialize( $meta ) );
			} else {

				// Check user status before sending email.
				$user_id = email_exists( $signup->user_email );

				if ( ! empty( $user_id ) && 2 != self::check_user_status( $user_id ) ) {

					// Status is not 2, so user's account has been activated.
					$result['errors'][ $signup->signup_id ] = array( $signup->user_login, esc_html__( 'the sign-up has already been activated.', 'buddypress' ) );

					// Repair signups table.
					self::validate( $signup->activation_key );

					continue;

				// Send the validation email.
				} else {
					$salutation = $signup->user_login;
					if ( bp_is_active( 'xprofile' ) && isset( $meta[ 'field_' . bp_xprofile_fullname_field_id() ] ) ) {
						$salutation = $meta[ 'field_' . bp_xprofile_fullname_field_id() ];
					}

					bp_core_signup_send_validation_email( false, $signup->user_email, $signup->activation_key, $salutation );
				}
			}

			// Update metas.
			$result['resent'][] = self::update( array(
				'signup_id' => $signup->signup_id,
				'meta'      => $meta,
			) );
		}

		/**
		 * Fires after activation emails are resent.
		 *
		 * @since 2.0.0
		 *
		 * @param array $signup_ids Array of IDs to resend activation emails to.
		 * @param array $result     Updated metadata related to activation emails.
		 */
		do_action( 'bp_core_signup_after_resend', $signup_ids, $result );

		/**
		 * Filters the result of the metadata for signup activation email resends.
		 *
		 * @since 2.0.0
		 *
		 * @param array $result Updated metadata related to activation emails.
		 */
		return apply_filters( 'bp_core_signup_resend', $result );
	}

Expand full source code Collapse full source code


Top ↑

Changelog #Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes #User Contributed Notes

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

Proudly powered by WordPress