Last active
February 27, 2026 13:45
-
-
Save yuriinalivaiko/61e025eaa52eb83cc33a42e51240e114 to your computer and use it in GitHub Desktop.
Ultimate Member customization. Code snippets for email notifications.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Disable email notifications for specific roles. | |
| * | |
| * @param bool $disabled Does an email is disabled? Default: false. | |
| * @param string $email Email address for sending. | |
| * @param string $template Email template. | |
| * @param array $args Arguments for sending email. | |
| * @return bool Return true to stop mailing. | |
| */ | |
| function my_disable_email_notification_sending( $disabled, $email, $template, $args ) { | |
| // List the roles for which email notifications should be disabled. | |
| $roles = array( | |
| 'contributor', | |
| 'um_pending-member', | |
| ); | |
| $user = get_user_by( 'email', $email ); | |
| if ( $user ) { | |
| $user_roles = UM()->roles()->get_all_user_roles( $user->ID ); | |
| if ( array_intersect( $roles, $user_roles ) ) { | |
| $disabled = true; | |
| } | |
| } | |
| return $disabled; | |
| } | |
| add_filter( 'um_disable_email_notification_sending', 'my_disable_email_notification_sending', 10, 4 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Add the "Bcc" header to the "Account Updated" email. | |
| * Send the mail copy to the website admins. | |
| * | |
| * @param string $subject Email subject. | |
| * @param string $template Email template key. | |
| */ | |
| function my_um_email_changedaccount_email_bcc( $subject, $template ) { | |
| if ( 'changedaccount_email' === $template ) { | |
| $bcc = um_multi_admin_email(); | |
| UM()->mail()->headers .= 'Bcc: ' . implode( ',', $bcc ) . "\r\n"; | |
| } | |
| return $subject; | |
| } | |
| add_filter( 'um_email_send_subject', 'my_um_email_changedaccount_email_bcc', 10, 2 ); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code is an example for the Ultimate Member plugin.
Related documentation: Emails Tab, Placeholders for email templates