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();       }      

KVM bridge networking: First ARP packet gets answered by wrong host

I have a host ( Linux server with KVM and one Linux server as virtualized guest ( The guest uses a network bridge and both host and guest are reachable over the same network interface card.

My issue is that the first ARP packet asking for the IP of my virtualized guest, in this example always gets answered by my host machine with the wrong MAC address. The second ARP packet however always finds its way to the guest and gets answered correctly. Needles to say that this is something that brings trouble…

$   arping -I wlp4s0 ARPING from wlp4s0 Unicast reply from [10:7B:44:80:E0:85]  3.752ms Unicast reply from [52:54:00:8D:A2:C8]  3.838ms Unicast reply from [52:54:00:8D:A2:C8]  2.591ms 
3: enp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000     link/ether 10:7b:44:80:e0:85 brd ff:ff:ff:ff:ff:ff     inet brd scope global noprefixroute enp5s0        valid_lft forever preferred_lft forever     inet6 fe80::127b:44ff:fe80:e082/64 scope link         valid_lft forever preferred_lft forever 6: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000     link/ether 52:54:00:f9:4b:f9 brd ff:ff:ff:ff:ff:ff     inet brd scope global virbr0        valid_lft forever preferred_lft forever 7: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000     link/ether 52:54:00:f9:4b:f9 brd ff:ff:ff:ff:ff:ff 10: macvtap0@enp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 500     link/ether 52:54:00:8d:a2:c8 brd ff:ff:ff:ff:ff:ff     inet brd scope global noprefixroute macvtap0        valid_lft forever preferred_lft forever     inet6 fe80::5054:ff:fe8d:a2c8/64 scope link         valid_lft forever preferred_lft forever 
virsh # iface-dumpxml macvtap0 <interface type='ethernet' name='macvtap0'>   <mtu size='1500'/>   <link speed='1000' state='up'/>   <mac address='52:54:00:8d:a2:c8'/> </interface> 
virsh # iface-dumpxml enp5s0 <interface type='ethernet' name='enp5s0'>   <mtu size='1500'/>   <link speed='1000' state='up'/>   <mac address='10:7b:44:80:e0:85'/> </interface> 
virsh # version Compiled against library: libvirt 4.5.0 Using library: libvirt 4.5.0 Using API: QEMU 4.5.0 Running hypervisor: QEMU 3.0.0 

Does someone have an idea what might be the problem? Or how to fix it? I also looked at a tcpdump from the guest and the first ARP packet never arrives there.

Force Custom Post Type Status to ‘Future’ on first Save or Publish

I have a custom post type setup for events. I set the time/date for the event using Advance Custom Fields. I would like to set the publish date from the ACF value as well. I am very close to having this working properly.. My site saves the publish date on save, but it sets the post status to ‘published’ instead of ‘future’.

Here is the code I am using in my functions.php to set the post_date:

function my_acf_save_post( $  post_id ) {     $  acfDate = get_field('alert_time', $  post_id);     $  my_post = array();     $  my_post['ID'] = $  post_id;     $  my_post['post_date'] = $  acfDate;     wp_update_post( $  my_post );  } 

My front end is setup to display both published and future dates. I have an opt-in notification system that sends out an email when an event moves from future to published. When I initially save the event, it sets itself to published, which sends out an unwanted email. If there is any way to make that function above force the status to ‘future’, it would be a life saver. I have tried a bunch of different ideas but couldn’t get any of them to work.

Ubuntu installation stuck after first reboot on encryption password screen

Ubuntu installation stuck at the encryption password screen

I’ve just installed Ubuntu without any problem using normal installation.

My GPU is Nvidia and Ubuntu is installed on SSD. (I’ve another HDD)

Then I decided to try the encryption feature as shown below.

enter image description here

Unfortunately, right after the first reboot, it just stuck at the encryption password screen. (this is not my actual screenshot, the image was taken from

The actual message on my screen after I entered the password is cryptsetup (nvme0n1p3_crypt):set up successfully and it just stuck there like forever.

enter image description here

If you need more info to solve this issue, please let me know.

First C Program- Mastermind

This is my first full program I’ve written in C. It took me about 2 hours to pull together today. Looking for any sort of feedback on the code, formatting, cleanliness etc. I didn’t follow any guides or tutorials, but did have some existing C++ knowledge and knowledge in other languages.


#include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <string.h> #include <ctype.h>  #define RESET  "\x1B[0m" #define BLOCK  "█"  #define RED   "\x1B[31m" BLOCK RESET #define GRN   "\x1B[32m" BLOCK RESET #define YEL   "\x1B[33m" BLOCK RESET #define BLU   "\x1B[34m" BLOCK RESET #define MAG   "\x1B[35m" BLOCK RESET #define CYN   "\x1B[36m" BLOCK RESET #define WHT   "\x1B[37m" BLOCK RESET  #define RED_C   "\x1B[31m" #define GRN_C   "\x1B[32m" #define YEL_C   "\x1B[33m" #define BLU_C   "\x1B[34m" #define MAG_C   "\x1B[35m" #define CYN_C   "\x1B[36m" #define WHT_C   "\x1B[37m"  #define COLORS 6 #define LENGTH 4  enum Colors {     red,     green,     yellow,     blue,     magenta,     cyan,     white };  static const enum Colors Color_map[] = {red, green, yellow, blue, magenta, cyan, white};  void *generate_colors(enum Colors *buffer) {     int power = pow(COLORS + 1, LENGTH);     int colors_integer = rand() % power;      for (int i = 0; i < LENGTH; ++i)     {         int remainder = colors_integer % (COLORS + 1);         int divisor = colors_integer / (COLORS + 1);          buffer[i] = Color_map[remainder];          colors_integer = divisor;     } }  int convert_input(char *input, enum Colors *buffer) {     for (int c = 0; c < strlen(input); ++c)     {         char character = tolower(input[c]);          switch (character)         {             case 'r':                 buffer[c] = red;                 break;              case 'g':                 buffer[c] = green;                 break;              case 'y':                 buffer[c] = yellow;                 break;              case 'b':                 buffer[c] = blue;                 break;              case 'm':                 buffer[c] = magenta;                 break;              case 'c':                 buffer[c] = cyan;                 break;              case 'w':                 buffer[c] = white;                 break;              default:                 return 1;         }     }      return 0; }  char *color_to_char(enum Colors color) {     switch (color)     {         case red:             return RED;         case green:             return GRN;         case yellow:             return YEL;         case blue:             return BLU;         case magenta:             return MAG;         case cyan:             return CYN;         default:             return WHT;     } }  int main() {     srand(time(NULL));      enum Colors selected_colors[4];     generate_colors(selected_colors);      int guessed = 0;      do {         char input[LENGTH];         scanf("%s", input);          if (strlen(input) == LENGTH)         {             enum Colors converted[LENGTH];             int contains_unmatched = convert_input(input, converted);              int correct_place = 0;             int correct_color = 0;              if (contains_unmatched)             {                 printf("Please only choose characters from " RED_C "R, " GRN_C "G, " YEL_C "Y, " BLU_C "B, " MAG_C "M, " CYN_C "C, " WHT_C "W" RESET ".\n");             }             else             {                 printf("You guessed: ");                  for (int i = 0; i < LENGTH; ++i)                 {                     enum Colors color = converted[i];                     enum Colors actual = selected_colors[i];                      if (color == actual)                         ++correct_place;                      else                      {                         for (int j = 0; j < LENGTH; ++j)                         {                             if (j != i)                             {                                 enum Colors current = selected_colors[j];                                  if (color == current)                                 {                                     ++correct_color;                                     break;                                 }                             }                         }                     }                      printf("%s", color_to_char(converted[i]));                 }                  if (correct_place == LENGTH)                 {                     printf("Well done! You got it right. Goodbye");                     return 0;                 }                 else                 {                     printf("\n %d correct color\n %d correct place and color\n", correct_color, correct_place);                 }             }         }         else         {             printf("Please enter 4 characters.\n");         }     } while (!guessed);      return 0; } 

Have file always listed first in Google Drive directory

When viewing Google Drive in Grid View, is there a way to have a specific file always listed first within a directory?

One obvious solution is to add something like “000” to the beginning of the file (e.g. 000 My Desired First File) so that it gets sorted to the top, but I’m looking for a non-hacky way to “pin” a file at the top of the list.

Example:   - My Desired First File  - Apple File  - Banana File  - Cat File  - Dog File 

Behaviors are only called the first time a view is loaded

On a Drupal 8 site I have a world map where the user can click on a country; a view with content is then loaded with AJAX using a custom module and the following JavaScript.

(function($  , Drupal, drupalSettings, window, document) {   Drupal.behaviors.worldmap = {     attach(context, settings) {       console.log('behaviors called');       $  ('#map-container', context).once('addmap').each( () => {         let map = new InteractiveMap('.interactive-map', (country) => {           let id = settings.worldmap.yearsnids[country];           if(!id) {             id = 0;           }           console.log('id');           let ajax_settings = {             url: '/my_module/ajax/expand/' +                   settings.worldmap.ctype + "-infobox/" + id,           };           Drupal.ajax(ajax_settings).execute();         });         map.init();       }); ... 

I have a custom template for the view where I add a ajax link.

<a href="/my_module/ajax/expand/{{ fields.field_content_type.content|render|striptags|trim }}/{{ fields.nid.content|render|striptags|trim }}" class="button use-ajax">See the project</a> 

Clicking that link loads another view with more content. So basically a preview is loaded when the user clicks on a country, and a link in the preview then loads the full content if clicked.

Both the preview and the content (also a view), is loaded from my_module with an AjaxResponse:

namespace Drupal\my_module\Controller; use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\ReplaceCommand; use Drupal\Core\Controller\ControllerBase;  class my_moduleController extends ControllerBase {   public function loadContent($  method, $  action, $  type, $  nid) {     $  response = new AjaxResponse();     // logic to determine which action and type we want to load      ...     $  build['view'] = [       '#type' => 'view',       '#name' => $  viewname,       '#display_id' => $  did,       '#arguments' => [$  nid],     ];     $  response->addCommand(new ReplaceCommand($  replaceClass,                            $  build, ['fadeIn']));     return $  response;   } } 

This all works, but the link in the preview only works for the first preview loaded. In every other preview loaded, clicking the link sends the user to the actual ajax-path (eg., and the content that should have been rendered to the page are displayed like json in a textbox:

[{"command":"settings","settings":{"pluralDelimiter":"\u0003","ajaxPageState": ... 

When the page with the map is loaded, and first time the preview is loaded, ‘behaviors called’ prints to the console – the link to load the full content works. On subsequent times, clicking on a country loads the preview, but behaviors aren’t called at all. ‘id’ gets printed to the console every time I click.

This is the HTML structure:

<div class="interactive-map">    <div id="map-container"></div>    <div class="info-box">      <div class="info-box__content">         <div class="placeholder"></div>     </div>   </div> </div> <div class="full-content-wrapper">   <div class="placeholder"></div> </div> 

The preview is loaded into the info-box__content div, which is outside the #map-container.

Prevent users from entering honorifics (Mr. / Mrs. / Ms.) in the First Name field

We have a high-throughput User Info intake form that get thousands of submissions everyday. The form, among other fields, has fields for First Name and Last Name. The form text is translated to the regions where we are getting the users from. However we still see folks entering Mr. Ms. Mrs Dr. etc instead of the First Name. And Full Name in the Last Name field.

We are adding field validation to prevent users from entering these honorifics in the Firstname field.

However I am wondering if there are other things that we can do to make it more clear to the end-users that they are supposed to enter their First Name and not honorifics.

p.s. We don’t want to add a Title field, like some other sites do.

Report the date/column header for the first and last non-zero entries for each client/row

I have a sheet with client names (Column A) and the number of visits to the business by mm-yyyy (Columns B – AC). I’m trying to find the first month that they visited the business and the last month we’ve seen them.

I have attached a screenshot and I have also published a small section of the sheet.

I have been struggling with this for a week and have gotten nowhere. I would greatly appreciate any help.

Click here for Sample Data