简体   繁体   中英

How to create a second login page on Drupal Commerce

I am using Commerce Kickstart to create an e-commerce marketplace and I am wondering how I can create a second login page that can be used by the merchants.

The standard login page is generated at http://website.com/user/login . How would I be able to create another login page at let's say http://website.com/user/merchant_login . The page itself will function exactly the same as the login, with slight changes in aesthetics, like taking off the register link, as we will generate the login information for the merchants.

I can see that the form is being generated at commerce_kickstart_user_form_alter through specified form_ids so I should be able to simply add the details for the merchant form there. My main question is how will the page/form be generated when they visit a url of my choosing?

You just need to create a custom page:

Assuming that your custom module is called custom_merchant the code should be something like this:

function custom_merchant_menu() {
  $items = array();

  $items['user/merchant_login'] = array(
    'page callback' => 'custom_merchant_login_callback',
    'page arguments' => array(true),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
);

  return $items;
}

function custom_merchant_login_menu_alter(&$items) {
  $items['user']['page callback'] = 'custom_login_user_page';
}

function custom_merchant_login_callback($show = false) {
  global $user;
  if ($user->uid) {
    menu_set_active_item('user/'. $user->uid);
    return menu_execute_active_handler();
  } else if ($show) {
    return drupal_get_form('user_login');
  }
  drupal_not_found();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM