0

I'm trying to find where to go in Drupal to find out how a user register form is displayed.

If the url is user/register, a person is routed to a standard registration form.

However, if the url is user/register?destination=voucher, then that person is routed to a user registration form that mimics our popup modal registration form, however, is not in a popup. This is not the regular registration form.

I want to find where this is set so that if a destination parameter is in the url, to go to the standard registration form.

1

The drupal_get_form() returns a form array for rendering. In your case drupal_get_form('user_register_form'). You can use drupal_render() with the result to render the html output.

If you need to override the form, use hook_form_alter() and change the $form_state['redirect'][] = 'your/redirect/path'. Also try removing the destination param with unset($_GET['destination']).

Here are some references:

  • I found where that is called. In user.module in the user_menu function there is this: ` $items['user/register'] = array( 'title' => 'Create new account', 'page callback' => 'drupal_get_form', 'page arguments' => array('user_register_form'), 'access callback' => 'user_register_access', 'type' => MENU_LOCAL_TASK, ); ` How do I get it to recognize user/register?destination=tester or anything after register? – Don Sevcik Feb 9 '12 at 17:03
  • I tried $items['user/register%'] but it still gives me that other registration page, the default registration page. – Don Sevcik Feb 9 '12 at 20:37
  • I also tried $items['%user/register'] and I get an access denied for both paths, user/register and user/register?destination=tester – Don Sevcik Feb 9 '12 at 20:52
  • I also tried I['user/%register'] and I get an access denied for both paths, user/register and user/register?destination=tester – Don Sevcik Feb 9 '12 at 21:03
  • If I force drupal_deliver_html_page function to recognize that user/register?destination=**** should be user/register, it goes to the right page, I just need it to render the content of user/register. I hacked this in common.inc drupal_deliver_html_page. – Don Sevcik Feb 9 '12 at 22:45
0

The way I'd do it is write a very small custom module. I'd assume you know the ID of your custom register form, so replace the value of $id_of_custom_register_form variable with the id of your custom register form on function custom_module_register_page(). Here's the code:

custom_module.info:

name = "Custom Module"
description = "Custom Module alters user/register menu"
dependencies[] = user
core = "7.x"
package = "Other"

custom_module.module:

/**
 * Implementation of HOOK_menu_alter()
 */
function custom_module_menu_alter(&$items) {
  // Change the function that returns the page content with
  // our custom function that checks the destination parameter
  // and return the appropriate form
  $items['user/register']['page callback'] = '_custom_module_register_page';

  // Empty the arguments array
  $items['user/register']['page arguments'] = array();
}

/**
 * Custom page callback for user/register path
 */
function _custom_module_register_page() {
  $id_of_custom_register_form = 'id_of_my_custom_register_form';  

  // If destination is set return $id_of_my_custom_register_form form
  if(isset($_GET['destination'])) {
    $form_id = $id_of_my_custom_register_form;
  }
  // Otherwise return normal register form
  else {
    $form_id = 'user_register_form';
  }

  return drupal_get_form($form);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.