Skip to main content
Category:

Delete users that never logged in in drupal 8

 

Example how to delete users that never logged in in drupal 8

 

use  \Drupal\user\Entity\User; 

 $ids = \Drupal::entityQuery('user')->execute();
  $users = User::loadMultiple($ids);
  foreach($users as $user) {
    if (!$user->getLastAccessedTime()) {
      $user->delete();
    }
  }

Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts

Search

Page Facebook