Skip to content

Don't assume that admin email is associated with an existing user #37

@gazer22

Description

@gazer22

When adding admin as a bcc on membership expiration emails, the code fails if there isn't a wordpress user associated with the admin email. As we use a generic admin address, there isn't one.

Recommended adjustment to pmproeewe_add_admin_as_bcc():

function pmproeewe_add_admin_as_bcc( $headers ) {
	$a_email = get_option( 'admin_email' );
	$admin   = get_user_by( 'email', $a_email );
	// $headers[] = "Bcc: {$admin->first_name} {$admin->last_name} <{$admin->user_email}>";
	if ( $admin && isset( $admin->first_name, $admin->last_name, $admin->user_email ) ) {
		$headers[] = "Bcc: {$admin->first_name} {$admin->last_name} <{$admin->user_email}>";
	} elseif ( $a_email && is_email( $a_email ) ) {
		$headers[] = "Bcc: {$a_email}";
	}

	return $headers;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions