I am trying to create a new Email Template for the Account object using hook_form_alter. Here is how I create the template:
function my_module_form_user_admin_settings_alter(&$form, &$form_state, $form_id) {
// Adds the Course Link email template to the Account Settings form
$form('email_course_link') = (
'#type' => 'details',
'#title' => t('Course link'),
'#description' => t('Edit the course link e-mail messages sent to mobile app users.'),
'#group' => 'email',
);
$form('email_course_link')('user_mail_course_link_subject') = (
'#type' => 'textfield',
'#title' => t('Subject'),
'#maxlength' => 180,
);
$form('email_course_link')('user_mail_course_link_body') = (
'#type' => 'textarea',
'#title' => t('Body'),
'#rows' => 15,
);
}
This adds the email template to my Account Settings form, but I am having two issues:
-
When I go to edit the template and hit save configurations, nothing gets saved. The subject and body edits I made are wiped out and they no longer exist.
-
When I go to use the template via
_user_mail_notify('email_course_link', $user)
I get NULL as the response and there are zero errors to be found and I never get the email…
What else am I missing here?