Filter uncanny-learndash-groups

ulgm_mail_subject

Filters the subject line of emails sent by the plugin, allowing for customization before they are dispatched.

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

Description

Filters the subject line of emails sent by the plugin. Developers can modify the email subject for notifications, alerts, or transactional emails. This hook provides a clean way to personalize or alter the subject content before it's sent to recipients.


Usage

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

Parameters

$subject (mixed)
This parameter contains the email subject line that will be sent.

Return Value

The filtered value.


Examples

/**
 * Example function to modify the email subject for the Ultimate SMS and Email Gateway.
 * This example appends a site-specific prefix to the subject line.
 *
 * @param string $subject The original email subject.
 * @return string The modified email subject.
 */
add_filter( 'ulgm_mail_subject', function( $subject ) {
    // Get the site name or a custom identifier from WordPress options.
    // This is just an example; you might fetch a site title, a specific plugin setting, etc.
    $site_prefix = get_bloginfo( 'name' );

    // Ensure the prefix is not empty before appending.
    if ( ! empty( $site_prefix ) ) {
        // Append the site prefix to the subject line.
        $subject = '[' . esc_html( $site_prefix ) . '] ' . $subject;
    }

    return $subject;
}, 10, 1 );

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/classes/helpers/shared-functions.php:916

public static function wp_mail( $to, $subject, $body, $headers = array(), $attachment = array() ) {
		$body       = do_shortcode( $body );
		$subject    = do_shortcode( $subject );
		$to         = apply_filters( 'ulgm_mail_to', $to );
		$subject    = apply_filters( 'ulgm_mail_subject', html_entity_decode( $subject ) );
		$body       = apply_filters( 'ulgm_mail_body', html_entity_decode( $body ) );
		$headers    = apply_filters( 'ulgm_mail_headers', $headers );
		$attachment = apply_filters( 'ulgm_mail_attachment', $attachment );

		return wp_mail( $to, $subject, $body, $headers, $attachment );
	}


Scroll to Top