IAMPETH Membership Site

Recently members.iampeth.com went live. I've been working on this site since November - creating custom modules to handle memberships and the convention registration.

One problem we ran into was the password reset page with the addressfield module. The addressfield module has an ajax country selection, which changes the address fields if necessary. But this refreshes the data for the form, which stopped users from being able to change their password and fill in their address at the same time. To fix this, I used a little trick:

function hook_form_user_profile_form_alter(&$form, &$form_state, $form_id) {
    // don't validate the password on a reset - this is how drupal currently handles skipping this validation
    if (!empty($form['#user']->uid) && !empty($_SESSION['pass_reset_' . $form['#user']->uid])) {
        $form['account']['current_pass_required_values']['#value'] = array();
    }
}

That's it: stop Drupal from validating the rebuilt form (when the country is changed), exactly the same way it does when the form is first generated.

Category: