BP_Email::set_cc( string|array|int|WP_User $cc_address, string $name = '', string $operation = 'replace' )

Set the email’s “cc” address and name.


Description Description

To set a single address, the first parameter is the address and the second the name. You can also pass a user ID or a WP_User object.

To set multiple addresses, for each array item, the key is the email address and the value is the name.


Parameters Parameters

$cc_address

(Required) Either a email address, user ID, WP_User object, or an array containing any combination of the above.

$name

(Optional) If $cc_address is a string, this is the recipient's name.

Default value: ''

$operation

(Optional) If "replace", $to_address replaces current setting (default). If "add", $to_address is added to the current setting.

Default value: 'replace'


Top ↑

Return Return

(BP_Email)


Top ↑

Source Source

File: bp-core/classes/class-bp-email.php

	public function set_cc( $cc_address, $name = '', $operation = 'replace' ) {
		$cc = ( $operation !== 'replace' ) ? $this->cc : array();

		if ( is_array( $cc_address ) ) {
			foreach ( $cc_address as $address ) {
				$cc[] = new BP_Email_Recipient( $address );
			}

		} else {
			$cc[] = new BP_Email_Recipient( $cc_address, $name );
		}

		/**
		 * Filters the new value of the email's "CC" property.
		 *
		 * @since 2.5.0
		 *
		 * @param BP_Email_Recipient[] $cc CC recipients.
		 * @param string|array|int|WP_User $cc_address Either a email address, user ID, WP_User object,
		 *                                             or an array containing any combination of the above.
		 * @param string $name Optional. If $cc_address is a string, this is the recipient's name.
		 * @param string $operation If "replace", $to_address replaced previous recipients. If "add",
		 *                          $to_address was added to the array of recipients.
		 * @param BP_Email $this Current instance of the email type class.
		 */
		$this->cc = apply_filters( 'bp_email_set_cc', $cc, $cc_address, $name, $operation, $this );

		return $this;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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