You are here

function _social_user_pass_reset_submit in Open Social 8.3

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_user/social_user.module \_social_user_pass_reset_submit()
  2. 8 modules/social_features/social_user/social_user.module \_social_user_pass_reset_submit()
  3. 8.2 modules/social_features/social_user/social_user.module \_social_user_pass_reset_submit()
  4. 8.4 modules/social_features/social_user/social_user.module \_social_user_pass_reset_submit()
  5. 8.5 modules/social_features/social_user/social_user.module \_social_user_pass_reset_submit()
  6. 8.6 modules/social_features/social_user/social_user.module \_social_user_pass_reset_submit()
  7. 8.7 modules/social_features/social_user/social_user.module \_social_user_pass_reset_submit()
  8. 8.8 modules/social_features/social_user/social_user.module \_social_user_pass_reset_submit()
  9. 10.3.x modules/social_features/social_user/social_user.module \_social_user_pass_reset_submit()
  10. 10.0.x modules/social_features/social_user/social_user.module \_social_user_pass_reset_submit()
  11. 10.1.x modules/social_features/social_user/social_user.module \_social_user_pass_reset_submit()
  12. 10.2.x modules/social_features/social_user/social_user.module \_social_user_pass_reset_submit()

Submit function for resetting password form.

1 string reference to '_social_user_pass_reset_submit'
social_user_form_user_form_alter in modules/social_features/social_user/social_user.module
Implements hook_form_FORM_ID_alter().

File

modules/social_features/social_user/social_user.module, line 154
The social user module alterations.

Code

function _social_user_pass_reset_submit($form, FormStateInterface $form_state) {
  $storage = $form_state
    ->getValues();
  $submitted_user_id = isset($storage['uid']) ? $storage['uid'] : '';

  // Only when there is actual user, and the actual user is changing his own
  // account we redirect. When you're editing others you don't want this.
  if (!empty($submitted_user_id) && \Drupal::currentUser()
    ->id() == $submitted_user_id) {
    $first_time_login = $form_state
      ->get('first_time_login');

    // If created & changed user time are the same, the user has never submitted
    // the user save form before. Which means we can redirect to user profile.
    if ($first_time_login) {
      $form_state
        ->setRedirect('entity.profile.type.user_profile_form', [
        'user' => $submitted_user_id,
        'profile_type' => 'profile',
        [],
      ]);
      $form_state
        ->set('first_time_login', FALSE);
    }
    else {

      // We redirect them to the home page stream.
      $form_state
        ->setRedirect('social_core.homepage');
    }
  }
}