hookalters_preprocess doesn't work on registration pages

Created on 1 October 2018, over 5 years ago
Updated 18 July 2023, 12 months ago

the following hooks, while working on the default registration page, and while important (I guess everyone will want to change the page title), don't work on the registration pages generated by the module. This makes the module unusable for me...

function hookalters_preprocess_page_title(&$variables) {

  if (\Drupal::routeMatch()->getRouteName() == 'multiple_registration.role_registration_page') {

    $variables['title'] = t('Tell us who you are...');
  }
}

function hookalters_preprocess_html(&$variables) {

  if (\Drupal::routeMatch()->getRouteName() == 'multiple_registration.role_registration_page') {

    $variables['head_title']['title'] = t('Company enrollment - create user');
  }

}
πŸ› Bug report
Status

Closed: won't fix

Version

2.4

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium dendreten

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡¬Nigeria chike Nigeria

    @Spanners most likely you have moved on from this but yesterday I had need of this and this code got me started as well then I made a tweak to accommodate what you were asking because I have same scenario. I made the code this way so I could set different titles for different registration pages,

    function reg_alters_preprocess_page_title(&$variables) {
    
        $current_route = \Drupal::routeMatch()->getRouteName();
    
        $current_path = \Drupal::service('path.current')->getPath();
    
        if ($current_route == 'multiple_registration.role_registration_page' && $current_path == '/user/register/custom_role') {
            $variables['title'] = t('Register as Custom Role');
          }
        if ($current_route == 'multiple_registration.role_registration_page' && $current_path == '/user/register/custom_role_2') {
            $variables['title'] = t('Register as Custom Role 2');
          }      
      }
Production build 0.69.0 2024