Customizing the User Registration page

Not applicable

(On Prem installation of Dev Portal)

Using the proposed method described here (https://www.drupal.org/node/1779256), I tried inserting the functions proposed into the "template" file of our Custom theme, updated the YOURTHEME to our theme name (even tried without updating the theme name and had the same result). When I upload the template file and refresh the site, there is a failure, the site does not render, crashes. I end up having to restore the original template file in our customized theme.

Any thoughts on why adding these functions would cause a failure?

Functions;

function YOURTHEME_theme(&$existing, $type, $theme, $path) { 
$hooks = array();
// Make user-register.tpl.php available
$hooks['user_register_form'] = array (
     'render element' => 'form',
     'path' => drupal_get_path('theme','YOURTHEME'),
     'template' => 'user-register',
     'preprocess functions' => array('YOURTHEME_preprocess_user_register_form'),
  );
return $hooks;
} 
function YOURTHEME_preprocess_user_register_form(&$vars) {
$args = func_get_args();
array_shift($args);
$form_state['build_info']['args'] = $args; 
  $vars['form'] = drupal_build_form('user_register_form', $form_state['build_info']['args']);
}
Solved Solved
1 10 1,111
1 ACCEPTED SOLUTION

Dear @Dylan Scott ,

Can you post your template.php ?

The best way to debug developer portal white screen of death is by enabling the PHP Error Messages.

You can do that easily. Paste below code just after <?php tag in Developer Portal root folder index.php to enable debug messages.

error_reporting(E_ALL);

ini_set('display_errors', TRUE);

ini_set('display_startup_errors', TRUE);

Cheers,

Anil Sagar

View solution in original post

10 REPLIES 10

Not applicable

Did I stump the community?? 😄

Hi @Dylan Scott ,

Works perfectly fine for me in the new theme created using apigee_responsive_starter_kit theme. Please find the steps i followed and see the code and actual results screenshot below.

  • My theme name is "anil_test"
  • Edited template.php , see code below
<?php
function anil_test_theme(&$existing, $type, $theme, $path) {
  $hooks = array();
   // Make user-register.tpl.php available
  $hooks['user_register_form'] = array (
     'render element' => 'form',
     'path' => drupal_get_path('theme','anil_test'),
     'template' => 'templates/user-register',
     'preprocess functions' => array('anil_test_preprocess_user_register_form'),
  );
  return $hooks;
}
function anil_test_preprocess_user_register_form(&$vars) {
  $args = func_get_args();
  array_shift($args);
  $form_state['build_info']['args'] = $args;
  $vars['form'] = drupal_build_form('user_register_form', $form_state['build_info']['args']);
}
  • Created 'user-register.tpl.php' inside templates folder
  • Edited 'user-register.tpl.php' with below code
<?php
print render($form['account']['name']);
print render($form['account']['mail']);
  • Clear Drupal Caches and Enable your theme if not enabled.
  • See results in below screenshot.

415-screen-shot-2015-05-09-at-92747-pm.png

Cheers,

Anil Sagar

Hi @asagar,

would you mind attaching your template.php file so I can compare our Responsive version to yours? We have what I believe you customized for us so, I'm unsure why we are having issues here but you are successful? Plus, I can't work with Ops until Monday to get them to check the logs to see why we get the failure.

Thanks!

Hi @Dylan Scott ,

When you use apigee_responsive_starterkit theme and follow instructions to create you own theme initially template.php is empty . Below code is all i have in template.php.

<?php
function anil_test_theme(&$existing, $type, $theme, $path) {
  $hooks = array();
   // Make user-register.tpl.php available
  $hooks['user_register_form'] = array (
     'render element' => 'form',
     'path' => drupal_get_path('theme','anil_test'),
     'template' => 'templates/user-register',
     'preprocess functions' => array('anil_test_preprocess_user_register_form'),
  );
  return $hooks;
}
function anil_test_preprocess_user_register_form(&$vars) {
  $args = func_get_args();
  array_shift($args);
  $form_state['build_info']['args'] = $args;
  $vars['form'] = drupal_build_form('user_register_form', $form_state['build_info']['args']);
}

You don't need ops to check logs. Login as administrator and navigate to Reports -> Recent Log Messages using admin menu on top.

@Anil Sagar thanks for the answer. If I want to customise the user edit form as well , is it just a case of adding another hook, another preprocess function and the php template ?

@mark.ferguson ,

Regarding, "If I want to customise the user edit form as well" , Can you please provide more context ? What exactly you mean "customise the user edit form" ?

/user/me/edit or /user/<id>/edit

I'd like the layout of that to mimic what I have on the registration page.

Dear @Dylan Scott ,

Can you post your template.php ?

The best way to debug developer portal white screen of death is by enabling the PHP Error Messages.

You can do that easily. Paste below code just after <?php tag in Developer Portal root folder index.php to enable debug messages.

error_reporting(E_ALL);

ini_set('display_errors', TRUE);

ini_set('display_startup_errors', TRUE);

Cheers,

Anil Sagar

Thanks @asagar, the error reporting helped to identify the problem. I'm still stumped on the "how", bc it happened again yesterday (and obviously the first time too), somehow, taking a copy of the template file from the custom folder, resulted in a copy of the Apigee Responsive template file. Don't ask me how, bc I don't even know the path to the Apigee theme. After a second attempt yesterday, I managed to download the correct template file from our theme folder (the same place I am downloading and uploading all the other customized code that I'm not having problems with) and added the two functions with success.

@Dylan Scott Glad issue is resolved 🙂