BP_Email::__construct( string $email_type )

Constructor.

Description

Set the email type and default "from" and "reply to" name and address.

Parameters

$email_type

(Required) Unique identifier for a particular type of email.

Source

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

153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
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

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.