BP_Email::__construct( string $email_type )
Constructor.
Description
Set the email type and default "from" and "reply to" name and address.
Parameters
- $email_type
-
(string) (Required) Unique identifier for a particular type of email.
Source
File: bp-core/classes/class-bp-email.php
public function __construct( $email_type ) { $this->type = $email_type; // SERVER_NAME isn't always set (e.g CLI). if ( ! empty( $_SERVER['SERVER_NAME'] ) ) { $domain = strtolower( $_SERVER['SERVER_NAME'] ); if ( substr( $domain, 0, 4 ) === 'www.' ) { $domain = substr( $domain, 4 ); } } elseif ( function_exists( 'gethostname' ) && gethostname() !== false ) { $domain = gethostname(); } elseif ( php_uname( 'n' ) !== false ) { $domain = php_uname( 'n' ); } else { $domain = 'localhost.localdomain'; } // This was escaped with esc_html on the way into the database in sanitize_option(). $from_name = wp_specialchars_decode( bp_get_option( 'blogname' ), ENT_QUOTES ); $from_address = "wordpress@$domain"; /** This filter is documented in wp-includes/pluggable.php */ $from_address = apply_filters( 'wp_mail_from', $from_address ); /** This filter is documented in wp-includes/pluggable.php */ $from_name = apply_filters( 'wp_mail_from_name', $from_name ); $this->set_from( $from_address, $from_name ); $this->set_reply_to( bp_get_option( 'admin_email' ), $from_name ); /** * Fires inside __construct() method for BP_Email class. * * @since BuddyPress 2.5.0 * * @param string $email_type Unique identifier for this type of email. * @param BP_Email $this Current instance of the email type class. */ do_action( 'bp_email', $email_type, $this ); }
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.