Quantcast
Channel: Active questions tagged users - Drupal Answers
Viewing all articles
Browse latest Browse all 468

Custom user_register_form for Auto Assign Role registration pages

$
0
0

I'm using a function[a] to get custom templates to work for all pages, including role registration pages set by Auto Assign Role. By setting the role registration path to user/register/<rolename> I'm able to use page--user--register--rolename.tpl.php to make custom pages.

enter image description here

What I'm trying to do now is use a custom user_register_form for each role registration page. Using this function[b] I'm able to use user-register-form.tpl.php to customize the registration form. This affects the form for both role pages though. I tried using the Field Permissions module, but because an anonymous user will be using both forms it's of no use here.

I'm thinking I need to change what user-register-form template the page itself is looking for, but I can't figure out how to do that.

a.

function THEMENAME_preprocess_page(&$vars) {  if (isset($vars['node'])) {    $suggests = &$vars['theme_hook_suggestions'];    $args = arg();    // Remove first argument of "node".    unset($args[0]);    $type = "page__type_{$vars['node']->type}";    $suggests = array_merge(      $suggests,      array($type),      theme_get_suggestions($args, $type)    );  }}

b.

 function THEMENAME_theme() {  $items = array();  $items['user_login'] = array('render element' => 'form','path' => drupal_get_path('theme', 'THEMENAME') . '/templates','template' => 'user-login','preprocess functions' => array('THEMENAME_preprocess_user_login'    ),  );  $items['user_register_form'] = array('render element' => 'form','path' => drupal_get_path('theme', 'THEMENAME') . '/templates','template' => 'user-register-form','preprocess functions' => array('THEMENAME_preprocess_user_register_form'    ),  );  $items['user_pass'] = array('render element' => 'form','path' => drupal_get_path('theme', 'THEMENAME') . '/templates','template' => 'user-pass','preprocess functions' => array('THEMENAME_preprocess_user_pass'    ),  );  return $items;}

Viewing all articles
Browse latest Browse all 468

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>