Hi,

Im trying to fix module:Password_reset.
The module works in 5. In Drupal 6 the hook menu: function password_reset_form_alter is not being executed and I have no clue what could be the reason. The system just ignores the execution.
Please help!

This is the code for the function for the hook menu in password_reset module in d5:

echo "password_reset module being executed"."<br><br>";

function password_reset_menu($may_cache) {
  global $user;
echo "function password_reset_menu being executed"."<br><br>";
  $items = array();

  
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/user/password_reset',
      'title' => t('Password reset'),
      'description' => t('Configure security questions for the password_reset module.'),
      'callback' => 'password_reset_admin_questions',
      'access' => user_access('administer site configuration')
    );
    $items[] = array(
      'path' => 'admin/user/password_reset/list',
      'title' => t('List'),
      'callback' => 'password_reset_admin_questions',
      'access' => user_access('administer site configuration'),
      'type' => MENU_DEFAULT_LOCAL_TASK
    );
    $items[] = array(
      'path' => 'admin/user/password_reset/add',
      'title' => t('Add question'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array('password_reset_admin_edit'),
      'access' => user_access('administer site configuration'),
      'type' => MENU_LOCAL_TASK,
      'weight' => 1
    );
    $items[] = array(
      'path' => 'admin/user/password_reset/edit',
      'title' => t('Edit question'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array('password_reset_admin_edit'),
      'access' => user_access('administer site configuration'),
      'type' => MENU_CALLBACK
    );
    $items[] = array(
      'path' => 'admin/user/password_reset/delete',
      'title' => t('Delete question'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array('password_reset_admin_delete'),
      'access' => user_access('administer site configuration'),
      'type' => MENU_CALLBACK
    );
  }
  else {
    // Override the default password recovery page rather having to perform
    // a string of form_alters and try overriding all the validation code
    // of the standard form which require the presence of e-mail form fields and
    // user fields.
    
    $items[] = array(
      'path' => 'user/password',
      'title' => t('Reset password'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array('password_reset_form'),
      'access' => !$user->uid,
      'type' => MENU_LOCAL_TASK
    );
  }

  return $items;
}

This is the code for the function for the hook menu in password_reset module in D6:


echo "password_reset module being executed"."<br><br>";

function password_reset_menu() {
  global $user;

  echo "function password_reset_menu being executed"."<br><br>";
  
  $items = array();

  $items['admin/user/password_reset'] = array(
    'title' => 'Password reset',
    'description' => 'Configure security questions for the password_reset module.',
    'page callback' => 'password_reset_admin_questions',
    'access arguments' => array('administer site configuration'),
    'file' => 'password_reset.admin.inc'
  );
  $items['admin/user/password_reset/list'] = array(
    'title' => 'List',
    'page callback' => 'password_reset_admin_questions',
    'access arguments' => array('administer site configuration'),
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'file' => 'password_reset.admin.inc'
  );
  $items['admin/user/password_reset/add'] = array(
    'title' => 'Add question',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('password_reset_admin_edit'),
    'access arguments' => array('administer site configuration'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 1,
    'file' => 'password_reset.admin.inc'
  );
  $items['admin/user/password_reset/edit/%'] = array(
    'title' => 'Edit question',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('password_reset_admin_edit', 4),
    'access arguments' => array('administer site configuration'),
    'type' => MENU_CALLBACK,
    'file' => 'password_reset.admin.inc'
  );
  $items['admin/user/password_reset/delete/%'] = array(
    'title' => 'Delete question',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('password_reset_admin_delete', 4),
    'access arguments' => array('administer site configuration'),
    'type' => MENU_CALLBACK,
    'file' => 'password_reset.admin.inc'
  );
  // Override the default password recovery page rather having to perform
  // a string of form_alters and try overriding all the validation code
  // of the standard form which require the presence of e-mail form fields and
  // user fields.
  
  
  $items['user/password'] = array(
    'title' => 'Reset password',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('password_reset_form'),
    'access callback' => 'user_is_anonymous',
    'type' => MENU_LOCAL_TASK
  );
  return $items;
}

These are the links:
http://weboldal.biz/drupal5/?q=user/password
http://weboldal.biz/drupal60/?q=user/password

Thanks for your help!

Comments

bzzz13’s picture

Menu hook calls only on menu rebuild. In all other situations menu loads from cache_menu table.
You can reset cache by loading page with modules list (/admin/build/modules).
Also you can use module "Devel" or "Administer menu". All of these have links to reset menu cache.

vojnar’s picture

menu cach is cleared unfortunately thats not the problem. good try, thanks

bzzz13’s picture

Are you trying to replace menu item "user/password"?
In Drupal 6 it's not correct way. Instead you should use hook_menu_alter().

Try to do like this:

function password_reset_menu_alter(&$items) {
  $items['user/password'] = array(
    'title' => 'Reset password',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('password_reset_form'),
    'access callback' => 'user_is_anonymous',
    'type' => MENU_LOCAL_TASK,
  );
}

By the way, use drupal_set_message instead echo

vojnar’s picture

Thanks for your help, this made it to work!

larryc11’s picture

To my great relief your snippet code snippet did exactly what I needed. Being unable to find the contact information of the password_reset module's author and being a Drupal newbie, I was going bonkers trying to find why it didn't work. I can't understand why the module author left out the password_reset_menu_alter(&$items) function or least provided a suggestion about it.

THANK YOU bzzz13!!!!