Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yuriinalivaiko/ca07d0dc320e99d6bfca77dc99c9bf63 to your computer and use it in GitHub Desktop.
Save yuriinalivaiko/ca07d0dc320e99d6bfca77dc99c9bf63 to your computer and use it in GitHub Desktop.
Hooks: Email
<?php
/**
* Hook: um_after_email_notification_sending
*
* Type: action
*
* Description: Fires after sending an email notification.
*
* @example https://github.com/ultimatemember/ultimatemember/blob/master/includes/core/class-mail.php#L456
*
* @package um\core
* @see um\core\Mail::send()
* @since 2.0
* @version 3.0
*
* @param string $email Comma-separated list of email addresses to send message.
* @param string $template Template key.
* @param array $args Template settings.
*/
function my_after_email_notification_sending( $email, $template, $args ) {
// your code here.
}
add_action( 'um_after_email_notification_sending', 'my_after_email_notification_sending', 10, 3 );
<?php
/**
* Hook: um_after_email_template_part
*
* Type: action
*
* Description: Fires after email template loading.
* May be used to display custom content below the main email message.
*
* @example https://github.com/ultimatemember/ultimatemember/blob/master/includes/core/class-mail.php#L242
* @link https://docs.ultimatemember.com/article/1015-umafteremailtemplatepart
*
* @package um\core
* @see um\core\Mail::get_email_template()
* @since 2.0
* @deprecated since version 3.0
*
* @param string $template Template key.
* @param string $template_path Template location.
* @param array $args Template settings.
*/
function my_after_email_template_part( $template, $template_path, $args ) {
// your code here.
}
add_action( 'um_after_email_template_part', 'my_after_email_template_part', 10, 3 );
<?php
/**
* Hook: um_before_email_notification_sending
*
* Type: action
*
* Description: Fires before sending an email notification.
*
* @example https://github.com/ultimatemember/ultimatemember/blob/master/includes/core/class-mail.php#L408
*
* @package um\core
* @see um\core\Mail::send()
* @since 2.0
* @version 3.0
*
* @param string $email Comma-separated list of email addresses to send message.
* @param string $template Template key.
* @param array $args Template settings.
*/
function my_before_email_notification_sending( $email, $template, $args ) {
// your code here.
}
add_action( 'um_before_email_notification_sending', 'my_before_email_notification_sending', 10, 3 );
<?php
/**
* Hook: um_before_email_template_part
*
* Type: action
*
* Description: Fires before email template loading.
* May be used to display custom content above the main email message.
*
* @example https://github.com/ultimatemember/ultimatemember/blob/master/includes/core/class-mail.php#L218
* @link https://docs.ultimatemember.com/article/1058-umbeforeemailtemplatepart
*
* @package um\core
* @see um\core\Mail::get_email_template()
* @since 2.0
* @deprecated since version 3.0
*
* @param string $template Template key.
* @param string $template_path Template location.
* @param array $args Template settings.
*/
function my_before_email_template_part( $template, $template_path, $args ) {
// your code here.
}
add_action( 'um_before_email_template_part', 'my_before_email_template_part', 10, 3 );
<?php
/**
* Hook: um_email_send_message_content
*
* Type: filter
*
* Description: Change email notification body.
*
* @example https://github.com/ultimatemember/ultimatemember/blob/master/includes/core/class-mail.php#L381
*
* @package um\core
* @see um\core\Mail::prepare_template()
* @since 2.0
* @version 3.0
*
* @param string $message Email body.
* @param string $template Template key.
* @param array $args Template settings.
*
* @return string Email body.
*/
function my_email_send_message_content( $message, $template, $args ) {
// your code here.
return $message;
}
add_filter( 'um_email_send_message_content', 'my_email_send_message_content', 10, 3 );
<?php
/**
* Hook: um_email_send_subject
*
* Type: filter
*
* Description: Change email notification subject.
* Used in the core to translate email subject.
*
* @example https://github.com/ultimatemember/ultimatemember/blob/master/includes/core/class-mail.php#L439
* @link https://docs.ultimatemember.com/article/1113-umemailsendsubject
*
* @package um\core
* @see um\core\Mail::send()
* @since 2.0
* @version 3.0
*
* @param string $subject Email subject.
* @param string $template Template key.
*
* @return string Email subject.
*/
function my_email_send_subject( $subject, $template ) {
// your code here.
return $subject;
}
add_filter( 'um_email_send_subject', 'my_email_send_subject', 10, 2 );
<?php
/**
* Hook: um_email_template_path
*
* Type: filter
*
* Description: Change email template location.
*
* @example https://github.com/ultimatemember/ultimatemember/blob/master/includes/core/class-mail.php#L189
* @link https://docs.ultimatemember.com/article/1116-umemailtemplatepath
*
* @package um\core
* @see um\core\Mail::get_email_template()
* @since 2.0
* @version 3.0 The $args parameter is removed.
*
* @param string $template_path Template location.
* @param string $template Template key.
* @param array $args Template settings.
*
* @return string Template location.
*/
function my_email_template_path( $template_path, $template, $args = array() ) {
// your code here.
return $template_path;
}
add_filter( 'um_email_template_path', 'my_email_template_path', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment