I should override registration form message "Registration successful. You are now logged in." with String Overrides module it does not work, because new text is long and every line with other style, it is in Drupal 7 I try to do it in template.php , but no my code is working. Can anyone help me?
2 Answers
You can check this message in hook_init it's working for me please try this code.
function custom_init() {
if (!empty($_SESSION['messages']['status'])) {
$message_text_to_remove = "Registration successful. You are now logged in.";
$key = array_search($message_text_to_remove, $_SESSION['messages']['status']);
if ($key !== FALSE) {
$_SESSION['messages']['status'][$key] = t('Greta Now your message changed');
}
}
}
Thankyou
-
Thank you very much. I used this code in template.php , but nothing have changed (– EviCommented Jul 29, 2017 at 5:59
-
Try this in custom module.It's working if you need i will create video for you. Commented Jul 29, 2017 at 6:12
-
Pankaj Thank you very much. I do not want to waste your time , I understood about module )– EviCommented Jul 29, 2017 at 11:50
-
-
Pankaj, I override it , everything is ok. Just want to know , how can I change message show time?– EviCommented Jul 31, 2017 at 12:55
Maybe someone will need this, I put it in template.php
function THEME_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'user_register_form') {
$form['account']['mail']['#attributes'] = array('placeholder'=> array(t('E-mail')));
$form['account']['name']['#prefix'] = '<div id="' . $form_id . '">';
$form['account']['name']['#prefix'] = '<h5 class="title">'.t('Create account').'</h5>';
$form['actions']['submit']['#suffix'] = '<span class="or">or</span><a href="'.$base_path.'/user/simple-fb-connect" class="fb_simple">CONTINUE WITH FACEBOOK</a>'.'<div class="back-to-login clearfix"><p>Already have an account?</p>' . '<a href="/user/login" class="use-ajax login-account" data-dialog="true">LOGIN</a>';
$form['actions']['submit']['#suffix'] .= '</div>';
drupal_set_message(' Your message');
}
}