@@ -268,6 +268,8 @@ function dosomething_user_form_alter(&$form, $form_state, $form_id) {
268268 _dosomething_user_add_signup_data($form);
269269 }
270270 else {
271+ // If this is not the registration form, then register submit handler
272+ // to update that existing Northstar user by their Drupal ID.
271273 $form['#submit'][] = 'dosomething_user_update_user';
272274 }
273275
@@ -424,13 +426,13 @@ function dosomething_user_validate_address_field($form, &$form_state) {
424426 }
425427}
426428
427- /**
429+ /**
428430 * Validates address for dosomething_user_info_form
429431 *
430432 * @param array $form
431- * A drupal form.
433+ * A drupal form.
432434 * @param array $form_state
433- * A drupal form_state array.
435+ * A drupal form_state array.
434436 */
435437function dosomething_user_validate_info_form_address ($form, &$form_state) {
436438 $first_name = $form_state['input']['first_name'];
@@ -439,7 +441,7 @@ function dosomething_user_validate_info_form_address ($form, &$form_state) {
439441 'country' => 'US',
440442 'thoroughfare' => $form_state['input']['street'],
441443 'premise' => $form_state['input']['sub_street'],
442- 'locality' => $form_state['input']['city'],
444+ 'locality' => $form_state['input']['city'],
443445 'administrative_area' => $form_state['input']['state'],
444446 'postal_code' => $form_state['input']['zipcode'],
445447 ];
@@ -466,7 +468,7 @@ function dosomething_user_validate_info_form_address ($form, &$form_state) {
466468}
467469
468470/**
469- * Validates that password is 6 or more characters long.
471+ * Validates that password is 6 or more characters long.
470472 *
471473 * @param array $form
472474 * A drupal form.
@@ -588,9 +590,15 @@ function dosomething_user_user_login(&$form_state, $account) {
588590
589591/**
590592 *
593+ * Custom form submission handler to update an existing user.
594+ * Triggered when making changes on the user profile form.
595+ *
596+ * @param $form
597+ * @param $form_state
591598 */
592599function dosomething_user_update_user($form, &$form_state) {
593600 if (!module_exists('dosomething_northstar')) { return; }
601+
594602 // Forward user updates into Northstar.
595603 dosomething_northstar_update_user($form_state);
596604}
@@ -775,7 +783,8 @@ function dosomething_user_is_old_person($user = NULL) {
775783}
776784
777785/**
778- * Custom login submission handler.
786+ * Custom login submission handler. This does _not_ trigger on log-ins
787+ * that happen post-registration.
779788 */
780789function dosomething_user_login_submit($form, &$form_state) {
781790 // Trigger an analytics event on login
@@ -815,7 +824,7 @@ function dosomething_user_authentication_submit($form, &$form_state) {
815824 dosomething_northstar_register_user($form_state);
816825 }
817826
818- // After all logins , except reportback pages redirect to page user was just on.
827+ // After all log-ins , except reportback pages redirect to page user was just on.
819828 if (isset($source) && stripos($source, 'reportback') > 0) {
820829 $form_state['redirect'] = drupal_get_path_alias($_SERVER['HTTP_REFERER']);
821830 }
@@ -1402,7 +1411,7 @@ function dosomething_user_info_form($form, &$form_state, $account) {
14021411 '#type' => 'textfield',
14031412 '#default_value' => $birthday,
14041413 '#description' => t("Format: M/D/YYYY"),
1405- '#field_suffix' => 'User age: ' . $age,
1414+ '#field_suffix' => 'User age: ' . $age,
14061415 );
14071416 $form['picture'] = array(
14081417 '#type' => 'fieldset',
0 commit comments