Jawaban:
print(drupal_render(drupal_get_form('user_register_form')));
print(drupal_render(drupal_get_form('user_login_block')));
Lihat user_register_form () dan user_login_block () untuk detailnya. Perhatikan bahwa user_register_form
ini adalah fungsi pembangun formulir yang tidak biasa: itu mengarahkan ulang dalam beberapa kasus.
Saya mengambil kode dari LoginToboggan. Ini yang saya dapat.
/**
* Implementation of hook_theme()
*/
function os_pages_theme() {
return array(
'os_pages_login_form' => array(
'variables' => array(
'register_form' => NULL,
'login_form' => NULL,
),
),
);
}
/**
* Logintobbogin provides the code to consolidate
* the registration page and the login page however
* it doesn't do exactly the way we want so we will
* take the code.
* @see http://drupal.org/project/logintoboggan
*/
/**
* Implementation of hook_menu_alter().
*/
function os_pages_menu_alter(&$callbacks) {
// Kill the tabs on the login pages.
$callbacks['user/login']['type'] = MENU_NORMAL_ITEM;
$callbacks['user/login']['page callback'] = 'os_pages_login_page';
$callbacks['user/register']['type'] = MENU_CALLBACK;
$callbacks['user/register']['page callback'] = 'os_pages_login_page';
$callbacks['user/register']['page arguments'] = array('register');
$callbacks['user/password']['type'] = MENU_CALLBACK;
$callbacks['user']['page callback'] = 'os_pages_login_page';
}
/**
* Menu callback for user/login
* creates a unified login/registration form (without tabs)
*/
function os_pages_login_page() {
global $user;
if ($user->uid) {
menu_set_active_item('user/' . $user->uid);
return menu_execute_active_handler(NULL, FALSE);
}
else {
// Title just clutters the interface...
drupal_set_title('');
$output = os_pages_login_form();
return $output;
}
}
/**
* Builds a unified login form.
*/
function os_pages_login_form() {
$register_form = drupal_get_form('user_register_form');
$login_form = drupal_get_form('user_login');
$rendered_register_form = drupal_render($register_form);
$rendered_login_form = drupal_render($login_form);
$variables = array(
'login_form' => $rendered_login_form,
'register_form' => $rendered_register_form,
);
$output = theme('os_pages_login_form', $variables);
return $output;
}
/**
* Theme function for unified login page.
*/
function theme_os_pages_login_form($variables) {
$register_form = $variables['register_form'];
$login_form = $variables['login_form'];
$output = '';
$output .= '<div class="login-form">';
// Add the login and registration forms in.
$output .= '<div id="register-form">' . $register_form . '</div>';
$output .= '<div id="login-form">' . $login_form . '</div>';
$output .= '</div>';
return $output;
}
Untuk ini, Anda perlu membuat halaman untuk Registrasi seperti ini
page-user-register.tpl.php
Dan cetak isi halaman seperti biasa. di halaman itu Anda bisa mencoba renderuser_login_block
Sumber daya tambahan
LoginToboggan melakukan ini untuk Anda: Instal, dan buka admin / config / system / logintoboggan; pilih "Sajikan halaman login / registrasi terpadu."