Created
April 10, 2017 08:45
-
-
Save gargsuchi/7c38515d6826532ec9efbde1865d8061 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function lotus_cron() { | |
$result = \Drupal::entityQuery("user") | |
->condition('login', strtotime('-6 months'), '<=') | |
->execute(); | |
$storage_handler = \Drupal::entityTypeManager()->getStorage("user"); | |
foreach ($result AS $user) { | |
$entity = $storage_handler->load($user); | |
$entity->block(); | |
$storage_handler->save($entity); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We can use \Drupal\user\Entity\User::load as well, its gonna be: