1

How can i add two registration form on single page

I had created two registration page using the Profile 2 module and given a custom path,eg:

http://localhost/dupal/member/register
http://localhost/dupal/non_member/register

How can I display that two form on single page
eg:http://localhost/dupal/user/register

1

Give a try to Profile2 Registration Path module:

Problem with Profile2 module: By default, the Profile2 module permits you to add fields from chosen profile types to the default user registration form. Unfortunately, there is only one user registration form. Thus, every user will be presented with these fields during registration. If you have two profile types targeted at two different audiences, you cannot have two separate registration forms.

Solution:

Profile2 Registration Path enables you to set a unique registration path for each Profile2 profile type. Users who register via that unique path will be presented with fields from the chosen profile type(s).


Alternatively another method to include multiple forms (e.g: FORM1 and FORM2) on same page is somewhat like below(however I am not sure where it will work with the profile2 forms):

$output = array();
$output['FORM1_DISPLAY'] = drupal_get_form('FORM_1_FORM_ID');
$output['FORM2_DISPLAY'] = drupal_get_form('FORM_2_FORM_ID');
return $output;
1

You can implement hook_menu_alter in your custom module and adds custom page callback for user/register menu item.

In your custom 'page callback' function, you can use drupal_get_form function to render the both form.

You can check the code snippets and may be it will help you.

<?php

/**
 * Implements hook_menu_item_alter()
 *
 */
function custom_feature_menu_alter(&$items) {

  //Configuring user login and register menu item
  $items['user/login']['type'] = MENU_CALLBACK;
  $items['user/login']['page callback'] = 'custom_feature_user_register';
  $items['user/login']['title'] = 'Login / Register';

  $items['user/register']['page callback'] = 'custom_feature_user_register';

  $items['user/register']['type'] = MENU_CALLBACK;
  $items['user/register']['title'] = 'Login / Register';

}

/**
 * Callback to display user login and register form
 */
function custom_feature_user_register() {

  //Addding user login form
  $output = '<div class="profile-left">';
  $output .= '<h3>Member Login</h3>';

  $output .= drupal_render(drupal_get_form('form_id_1'));
  $output .= '</div>';

  $output .= '<div class="profile-left">';
  $output .= '<h3>Register</h3>';

  $output .= drupal_render(drupal_get_form('form_id_1'));
  $output .= '</div>';

  return $output;
}

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.