Filter uncanny-learndash-toolkit

wp_mail_from_name

Filters the name that emails are sent from, allowing customization of the sender's display name.

add_filter( 'wp_mail_from_name', $callback, 10, 1 );

Description

Filters the sender name used for emails sent by WordPress. Developers can modify the default sender name, typically set via WordPress settings or plugins, before it's used in outgoing mail. This hook fires within the email sending process.


Usage

add_filter( 'wp_mail_from_name', 'your_function_name', 10, 1 );

Parameters

$this (mixed)
This parameter contains the current sender name that will be applied to emails.

Return Value

The filtered value.


Examples

add_filter( 'wp_mail_from_name', 'my_custom_wp_mail_from_name', 10, 1 );

/**
 * Changes the 'From' name for all outgoing emails.
 *
 * This function modifies the sender's name that appears in emails sent by WordPress.
 * It's useful for branding or when emails should appear to come from a specific
 * department or individual within an organization.
 *
 * @param string $current_from_name The current 'From' name.
 * @return string The new 'From' name.
 */
function my_custom_wp_mail_from_name( $current_from_name ) {
	// Replace 'Your Site Name' with your desired email sender name.
	$new_from_name = 'Your Site Name';
	return $new_from_name;
}

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/includes/class.DisableEmailsPHPMailerMock.php:190

}


		if ( $plugin->options['wp_mail_from'] ) {
			$this->phpmailer->From = apply_filters( 'wp_mail_from', $this->phpmailer->From );
		}
		if ( $plugin->options['wp_mail_from_name'] ) {
			$this->phpmailer->FromName = apply_filters( 'wp_mail_from_name', $this->phpmailer->FromName );
		}
		if ( $plugin->options['wp_mail_content_type'] ) {
			$this->phpmailer->ContentType = apply_filters( 'wp_mail_content_type', $this->phpmailer->ContentType );
		}
		if ( $plugin->options['wp_mail_charset'] ) {
			$this->phpmailer->CharSet = apply_filters( 'wp_mail_charset', $this->phpmailer->CharSet );
		}


Scroll to Top