0

I'm getting this error in my custom module.

[warning] Missing argument 1 for signin_menu(), called in /public_html/includes/menu.inc on line 2813 and defined signin.module:2

here is my code to create hook menu call back.

function signin_menu(&$items) {
  $items = array();

  $items['signin'] = array(
    'title' => 'Sign In',
    'description' => 'Sign In Form',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('user_login'),
    'access callback' => TRUE
  );

  return $items;
}
1

No need to pass arguments to hook_menu Just remove the param &$items:

/**
 * Implements hook_menu().
 */
function wa_simulator_menu() {
  $items = array();
  $items['signin'] = array(
    'title'           => 'Sign In',
    'description'     => 'Sign In Form',
    'page callback'   => 'drupal_get_form',
    'page arguments'  => array('user_login'),
    'access callback' => TRUE,
  );

  return $items;
}
  • I just used your code and my problem got solved. thank you so much. – Abdullah Zubair Oct 20 '18 at 4:01
2

In Drupal 6 and Drupal 7, hook_menu() implementations don't get any argument. That is the reason of the error message.
They got an argument in previous Drupal versions, but it was not passed by reference. It's probable you are getting confused between hook_menu() and hook_menu_alter(). The latter gets a $&items parameter, but the purpose of the hook is slightly different. (It's altering routes defined from other modules, rather than defining new routes.)

As side note, I would rather use the following code.

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

  $items['signin'] = array(
    'title' => 'Sign in',
    'description' => 'Sign in form',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('user_login'),
    'access callback' => 'user_is_anonymous',
  );

  return $items;
}

The login form should be visible only to anonymous users. Logged in users should not see it, since they already logged in, but the 'access callback' => TRUE line is making it accessible to every user, contrary to what Drupal (correctly) does.

  • Thank you so much for pointing me into right direction, now I have set 'access callback' => 'user_is_anonymous'. – Abdullah Zubair Oct 20 '18 at 10:07

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.