bp_core_deprecated_email_actions( bool|WP_Error $delivery_status, BP_Email $email )

Add support for pre-2.5 email actions.

Description

Parameters

$delivery_status

(bool|WP_Error) (Required) Bool if the email was sent or not. If a WP_Error, there was a failure.

$email

(BP_Email) (Required) Email object reference.

Return

(mixed)

Source

File: bp-core/deprecated/buddypress/2.5.php

function bp_core_deprecated_email_actions( $delivery_status, $email ) {
	$pre_2_5_emails = array(
		'activity-comment',
		'activity-comment-author',
		'core-user-registration',
		'core-user-registration-with-blog',
		'friends-request',
		'friends-request-accepted',
		'groups-details-updated',
		'groups-invitation',
		'groups-member-promoted',
		'groups-membership-request',
		'groups-membership-request-accepted',
		'groups-membership-request-rejected',
		'messages-unread',
		'settings-verify-email-change',
	);

	remove_action( 'bp_send_email_success', 'bp_core_deprecated_email_actions', 20 );
	$email_content = $email->get( 'content' );
	$email_subject = $email->get( 'subject' );
	$email_type    = $email->get( 'type' );
	$tokens        = $email->get( 'tokens' );
	add_action( 'bp_send_email_success', 'bp_core_deprecated_email_actions', 20, 2 );

	// Backpat for pre-2.5 emails only.
	if ( ! in_array( $email_type, $pre_2_5_emails, true ) ) {
		return;
	}

	if ( $email_type === 'activity-comment' ) {
		/**
		 * Fires after the sending of a reply to an update email notification.
		 *
		 * @since BuddyPress 1.5.0
		 * @deprecated BuddyPress 2.5.0 Use the filters in BP_Email. $params argument unset and deprecated.
		 *
		 * @param int    $user_id       ID of the original activity item author.
		 * @param string $email_subject Email notification subject text.
		 * @param string $email_content Email notification message text.
		 * @param int    $comment_id    ID for the newly received comment.
		 * @param int    $commenter_id  ID of the user who made the comment.
		 * @param array  $deprecated    Removed in 2.5; now an empty array.
		 */
		do_action( 'bp_activity_sent_reply_to_update_email', $tokens['original_activity.user_id'], $email_subject, $email_content, $tokens['comment.id'], $tokens['commenter.id'], array() );

	} elseif ( $email_type === 'activity-comment-author' ) {
		/**
		 * Fires after the sending of a reply to a reply email notification.
		 *
		 * @since BuddyPress 1.5.0
		 * @deprecated BuddyPress 2.5.0 Use the filters in BP_Email. $params argument unset and deprecated.
		 *
		 * @param int    $user_id       ID of the parent activity item author.
		 * @param string $email_subject Email notification subject text.
		 * @param string $email_content Email notification message text.
		 * @param int    $comment_id    ID for the newly received comment.
		 * @param int    $commenter_id  ID of the user who made the comment.
		 * @param array  $deprecated    Removed in 2.5; now an empty array.
		 */
		do_action( 'bp_activity_sent_reply_to_reply_email', $tokens['parent-comment-user.id'], $email_subject, $email_content, $tokens['comment.id'], $tokens['commenter.id'], array() );

	} elseif ( $email_type === 'core-user-registration' ) {
		if ( ! empty( $tokens['user.id'] ) ) {
			/**
			 * Fires after the sending of activation email to a newly registered user.
			 *
			 * @since BuddyPress 1.5.0
			 *
			 * @param string $email_subject   Subject for the sent email.
			 * @param string $email_content   Message for the sent email.
			 * @param int    $user_id         ID of the new user.
			 * @param string $recipient_email Email address of the new user.
			 * @param string $key             Activation key.
			 */
			do_action( 'bp_core_sent_user_validation_email', $email_subject, $email_content, $tokens['user.id'], $tokens['recipient.email'], $tokens['key'] );

		} else {
			/**
			 * Fires after the sending of the notification to new users for successful registration without blog.
			 *
			 * @since BuddyPress 1.5.0
			 * @deprecated BuddyPress 2.5.0 Use the filters in BP_Email. $meta argument unset and deprecated.
			 *
			 * @param string $admin_email        Admin Email address for the site.
			 * @param string $email_subject      Subject used in the notification email.
			 * @param string $email_content      Message used in the notification email.
			 * @param string $recipient_username The user's login name.
			 * @param string $recipient_email    The user's email address.
			 * @param string $key                The activation key created in wpmu_signup_blog().
			 * @param array  $meta               Removed in 2.5; now an empty array.
			 */
			do_action( 'bp_core_sent_user_signup_email', bp_get_option( 'admin_email' ), $email_subject, $email_content, $tokens['recipient.username'], $tokens['recipient.email'], $tokens['key'], array() );
		}

	} elseif ( $email_type === 'core-user-registration-with-blog' ) {
		/**
		 * Fires after the sending of the notification to new users for successful registration with blog.
		 *
		 * @since BuddyPress 1.5.0
		 * @deprecated BuddyPress 2.5.0 Use the filters in BP_Email. $meta argument unset and deprecated.
		 *
		 * @param string $admin_email        Admin Email address for the site.
		 * @param string $email_subject      Subject used in the notification email.
		 * @param string $email_content      Message used in the notification email.
		 * @param string $domain             The new blog domain.
		 * @param string $path               The new blog path.
		 * @param string $title              The site title.
		 * @param string $recipient_username The user's login name.
		 * @param string $recipient_email    The user's email address.
		 * @param string $key                The activation key created in wpmu_signup_blog().
		 * @param array  $meta               Removed in 2.5; now an empty array.
		 */
		do_action( 'bp_core_sent_blog_signup_email', bp_get_option( 'admin_email' ), $email_subject, $email_content, $tokens['domain'], $tokens['path'], $tokens['title'], $tokens['recipient.username'], $tokens['recipient.email'], $tokens['key_blog'], array() );

	} elseif ( $email_type === 'friends-request' ) {
		/**
		 * Fires after the new friend request email is sent.
		 *
		 * @since BuddyPress 1.5.0
		 * @deprecated BuddyPress 2.5.0 Use the filters in BP_Email.
		 *
		 * @param int    $friend_id     ID of the request recipient.
		 * @param string $email_subject Text for the friend request subject field.
		 * @param string $email_content Text for the friend request message field.
		 * @param int    $friendship_id ID of the friendship object.
		 * @param int    $initiator_id  ID of the friendship requester.
		 */
		do_action( 'bp_friends_sent_request_email', $tokens['friend.id'], $email_subject, $email_content, $tokens['friendship.id'], $tokens['initiator.id'] );

	} elseif ( $email_type === 'friends-request-accepted' ) {
		/**
		 * Fires after the connection request accepted email is sent.
		 *
		 * @since BuddyPress 1.5.0
		 * @deprecated BuddyPress 2.5.0 Use the filters in BP_Email.
		 *
		 * @param int    $initiator_id  ID of the friendship requester.
		 * @param string $email_subject Text for the friend request subject field.
		 * @param string $email_content Text for the friend request message field.
		 * @param int    $friendship_id ID of the friendship object.
		 * @param int    $friend_id     ID of the request recipient.
		 */
		do_action( 'bp_friends_sent_accepted_email', $tokens['initiator.id'], $email_subject, $email_content, $tokens['friendship.id'], $tokens['friend.id'] );

	} elseif ( $email_type === 'groups-invitation' ) {
		/**
		 * Fires after the notification is sent that a member has been invited to a group.
		 *
		 * @since BuddyPress 1.5.0
		 * @deprecated BuddyPress 2.5.0 Use the filters in BP_Email.
		 *
		 * @param int             $invited_user_id  ID of the user who was invited.
		 * @param string          $email_subject    Email notification subject text.
		 * @param string          $email_content    Email notification message text.
		 * @param BP_Groups_Group $group            Group object.
		 */
		do_action( 'bp_groups_sent_invited_email', $tokens['inviter.id'], $email_subject, $email_content, $tokens['group'] );

	} elseif ( $email_type === 'groups-member-promoted' ) {
		/**
		 * Fires after the notification is sent that a member has been promoted.
		 *
		 * @since BuddyPress 1.5.0
		 * @deprecated BuddyPress 2.5.0 Use the filters in BP_Email.
		 *
		 * @param int    $user_id       ID of the user who was promoted.
		 * @param string $email_subject Email notification subject text.
		 * @param string $email_content Email notification message text.
		 * @param int    $group_id      ID of the group that the user is a member of.
		 */
		do_action( 'bp_groups_sent_promoted_email', $tokens['user.id'], $email_subject, $email_content, $tokens['group.id'] );

	} elseif ( $email_type === 'groups-membership-request' ) {
		/**
		 * Fires after the notification is sent that a member has requested group membership.
		 *
		 * @since BuddyPress 1.5.0
		 * @deprecated BuddyPress 2.5.0 Use the filters in BP_Email.
		 *
		 * @param int    $admin_id           ID of the group administrator.
		 * @param string $email_subject      Email notification subject text.
		 * @param string $email_content      Email notification message text.
		 * @param int    $requesting_user_id ID of the user requesting membership.
		 * @param int    $group_id           ID of the group receiving membership request.
		 * @param int    $membership_id      ID of the group membership object.
		 */
		do_action( 'bp_groups_sent_membership_request_email', $tokens['admin.id'], $email_subject, $email_content, $tokens['requesting-user.id'], $tokens['group.id'], $tokens['membership.id'] );

	} elseif ( $email_type === 'groups-membership-request-accepted' || $email_type === 'groups-membership-request-rejected' ) {
		/**
		 * Fires after the notification is sent that a membership has been approved.
		 *
		 * @since BuddyPress 1.5.0
		 * @deprecated BuddyPress 2.5.0 Use the filters in BP_Email.
		 *
		 * @param int    $requesting_user_id ID of the user whose membership was approved.
		 * @param string $email_subject      Email notification subject text.
		 * @param string $email_content      Email notification message text.
		 * @param int    $group_id           ID of the group that was joined.
		 */
		do_action( 'bp_groups_sent_membership_approved_email', $tokens['requesting-user.id'], $email_subject, $email_content, $tokens['group.id'] );
	}
}

Changelog

Changelog
Version Description
BuddyPress 2.5.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.