Just that.
I need to enable ckeditor to write the text body for the welcome e-mail message at admin/config/people/accounts
How can I do this?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityJust that.
I need to enable ckeditor to write the text body for the welcome e-mail message at admin/config/people/accounts
How can I do this?
For all textarea fields there's text selector appear - you should select format, where ckeditor attached:
/**
* Implements hook_form_FORM_ID_alter() for user settings page.
*/
function MODULENAME_form_user_admin_settings_alter(&$form, &$form_state, $form_id) {
_MODULENAME_form_user_admin_settings_elements($form);
}
/**
* Scan through elements.
*/
function _MODULENAME_form_user_admin_settings_elements(&$elements) {
// Recurse through all children.
foreach (element_children($elements) as $key) {
if (isset($elements[$key]) && $elements[$key]) {
if (isset($elements[$key]['#type']) && ($elements[$key]['#type'] == 'textarea')) {
$elements[$key]['#type'] = 'text_format';
}
else {
_MODULENAME_form_user_admin_settings_elements($elements[$key]);
}
}
}
}
$elements[CERTAIN_ARRAY_PATH2ELEMENT]['#type'] = 'text_format';
without scanning through all elements.In my answer I'm only going to focus on Welcome (no approval required) email body field.
admin/config/content/formats
mymodule
with your own module nameCode:
/**
* Implement hook_form_alter().
*/
function mymodule_form_user_admin_settings_alter(&$form, &$form_state) {
// alter type textarea to text_format
$form['email_no_approval_required']['user_mail_register_no_approval_required_body']['#type'] = 'text_format';
// alter default format to full_html (you need to create this format before you assign it)
$form['email_no_approval_required']['user_mail_register_no_approval_required_body']['#format'] = 'full_html';
// add validation function to alter field value before submit (before saving it to variable tables)
$form['#validate'][] = 'mymodule_system_settings_form_validate';
}
function mymodule_system_settings_form_validate(&$form, &$form_state) {
// get submitted value
$html = $form_state['values']['user_mail_register_no_approval_required_body'];
// set value of the submitted value
form_set_value($form['email_no_approval_required']['user_mail_register_no_approval_required_body'], $html['value'], $form_state);
}
The reason I'm using validate function is to alter field value before submitting value and store it into variable
table. Without altering the value Drupal will store value as array (value, format) and users will start getting Array
as text instead of the actual text that you need them to see.
if the field format is choosen as long text
in the
admin/config/people/accounts/
click on modify then select
treatment: filter text