How to redirect users after password reset from first time user

I am using hook function in my module to redirect users accordingly as below.

function mymodule_user_login($  account) {  if (!$  account->getLastAccessedTime()) {   // The user has never logged in before.    return;  }  $  response = new RedirectResponse('MyModuleFormUrl');  $  response->send(); } 

First time users coming from their corresponding emails are getting redirected to change password page able to set new password and existing users are redirected to form page after successful login. But the problem is how to redirect users after successfully setting their password to my module form. From the code above I thought it should happen automatically but it isn’t. Can anyone suggest some ideas.

Edit to the Question: So as suggested below I tried both the ways but still after the new user clicks save button on password reset page(setting his new password), he is not getting redirected to mymodule form page. Below are the codes I tried.

Method 1:

    function MyModule_form_alter(&$  form, &$  form_state, $  form_id){     if($  _SESSION['first_time_login']==TRUE)     {        $  _SESSION['first_time_login']==FALSE;        $  form_state->setRedirect('url');     } 

Method 2:

    function mymodule_user_form_alter(&$  form,      \Drupal\Core\Form\FormStateInterface $  form_state, $  form_id)     {        foreach (array_keys($  form['actions']) as $  action) {         if (isset($  form['actions'][$  action]['#type']) && $  form['actions']          [$  action]['#type'] === 'submit') {         $  form['actions'][$  action]['#submit'][] = 'mymodule_form_submit';          }        }     }      function mymodule_form_submit(array $  form, FormStateInterface       $  form_state){          $  form_state['redirect'] = 'url';      } 

Final function which worked for me:

    function MyModule_form_alter(&$  form, &$  form_state, $  form_id){       if($  form_id == 'user_form')       {         foreach (array_keys($  form['actions']) as $  action) {            if (isset($  form['actions'][$  action]['#type']) && $  form['actions']             [$  action]['#type'] === 'submit')            {             $  form['actions'][$  action]['#submit'][] =                 '_MyModule_user_profile_submit';            }        }      }        function _MyModule_user_profile_submit($  form, &$  form_state)       {            $  response = new RedirectResponse('url');            $  response->send();       }      

Lubuntu 18.04.2 – reset audio driver?

I have multiple displays hooked up to multiple GPUs and one of the connections is via HDMI to a switch that is connected to an HDTV, so audio throughput (via HDMI) is required. I accomplished this with paprefs and the creation of a virtual audio device that combines both 3.5mm analog and digital sound so that both the speakers and HDTV have audio. The problem is that the switch (used because I need to connect more HDMI devices to the HDTV than it has HDMI ports) sometimes disconnects and this sometimes causes the TV to lose the audio, though not the video. A reboot fixes this, but I was wondering if there was a way to “reset” (meaning reload, while KEEPING the sound settings) the audio driver without having to wait for the whole PC to reboot.

cannot reset screen resolution

I cancelled an update after an hour of no activity following the box: “Failure to download extra data files” from flashplugin-installer. Ubuntu 14.04 now comes up in 640 x 480 resolution and I can’t seem to change it from the display settings. On booting I get a notice about there being no resolutions available. Ubuntu has also stopped connecting to WiFi. How can I revert to the situation before the update I cancelled ? I have W7 installed alongside 14.04 which is how I can send this to the forum.

Insufficient space after factory reset

Irulu expro x1plus

11GB available internal storage of 16GB

No additional external storage

Error notification: insufficient storage

Only factory installed apps

Deleting or disabling factory apps doesn’t help

Tablet – no dialer seen

Android 5.1.1 – no updates seem available

Firmware – 3.4.39

Have done factory reset attempting to fix – no help

Cached data – 0.92MB

Any suggestions?

Filters posts using AJAX and then reset query with a button

I am using ajax to filter a custom post type. I want to add a “reset” button that destroys the ajax session and shows all posts instead of the filter.

The filters are activated on change with query. Code attached.

jQuery

(function ($  ) {     $  (document).ready(function () {  jQuery(function($  ){     $  ('#filter').change(function(){         var filter = $  ('#filter');         $  .ajax({             url:filter.attr('action'),             data:filter.serialize(), // form data             type:filter.attr('method'), // POST             beforeSend:function(xhr){                 filter.find('.message').text('Applying Filters...');          },             success:function(data){                 filter.find('.message').text('');                $  ('#response').html(data);             }         });         return false;     });  }); }); })(jQuery); 

Form

<form action="<?php echo site_url() ?>/wp-admin/admin-ajax.php" method="POST" id="filter">      <?php global $  post;     $  args = array( 'post_type' => 'staff', 'numberposts' => -1, 'orderby' => 'title', 'order' => 'asc');      $  myposts = get_posts($  args);       echo '<select name="namefilter"><option value="">Search By Name</option>';     foreach ($  myposts as $  post) : setup_postdata($  post);       echo '<option value="' . $  post->post_name . '">' . $  post->post_title . '</option>';     endforeach;       echo '</select>';     wp_reset_postdata();?>      <?php         if ($  terms = get_terms('team_group', 'orderby=name')) :             echo '<select name="teamfilter"><option value="">Search By Group</option>';             foreach ($  terms as $  term) :                 echo '<option value="' . $  term->term_id . '">' . $  term->name . '</option>';             endforeach;             echo '</select>';         endif;     ?>     <?php         if ($  terms = get_terms('expertise', 'orderby=name')) :             echo '<select name="expertisefilter"><option value="">Search By Area of Expertise</option>';             foreach ($  terms as $  term) :                 echo '<option value="' . $  term->term_id . '">' . $  term->name . '</option>';             endforeach;             echo '</select>';         endif;     ?>      <!-- <button>Apply filters</button> -->     <div class="message"></div>     <input type="hidden" name="action" value="customfilter"> <input type="reset" id="configreset" value="Reset"> </form> <div id="response">  </div> 

PHP Function

function my_filters() {  $  args = array(     'orderby'        => 'title',     'post_type'      => 'staff',     'posts_per_page' => -1, );   // Has to be empty() becuase there is a default answer. So even if nothing was picked, isset() will return true. if ( !empty($  _POST['namefilter'])) {   $  args['name'] = $  _POST['namefilter'];  };  // Only Team Filter if ( !empty($  _POST['teamfilter']) && empty($  _POST['expertisefilter'])) {   $  args['tax_query'] = array(          array(           'taxonomy' => 'team_group',           'field'    => 'id',           'terms'    => $  _POST['teamfilter']         ),     ); };  // Only expertise Filter if ( empty($  _POST['teamfilter']) && !empty($  _POST['expertisefilter'])) {   $  args['tax_query'] = array(          array(           'taxonomy' => 'expertise',           'field'    => 'id',           'terms'    => $  _POST['expertisefilter']         ),     ); };   // Both taxonomies if ( !empty($  _POST['teamfilter']) && !empty($  _POST['expertisefilter'])) {   $  args['tax_query'] = array(       'relation'       => 'AND',           array(             'taxonomy' => 'team_group',             'field'    => 'id',             'terms'    => $  _POST['teamfilter']           ),           array(             'taxonomy' => 'expertise',             'field'    => 'id',             'terms'    => $  _POST['expertisefilter']           )      ); };          $  query = new WP_Query($  args);          if ($  query->have_posts()) :             while ($  query->have_posts()): $  query->the_post(); ?>                //Display my content here              <?php endwhile;          wp_reset_postdata(); else :             echo 'No posts found';         endif;          die();     }      add_action('wp_ajax_nopriv_customfilter', 'my_filters');     add_action('wp_ajax_customfilter', 'my_filters'); 

Serial Number Got Changed After Factory Reset

After “Factory Resetting” my tablet I realized that the serial Number was changed (it is now a weird number 0123456789ABCDEF).

Why did this happen? How do I go about returning it to its original SN? How do I prevent it from happening again?

I have seen some options of changing the SN number but I’m reluctant to try them since the programs they use doesn’t look like official (safe) programs.