I’m making an attempt to delete customers with no permissions/roles from our websites. Drupal Developer consumer’s node must be stored.
This code works when Drupal Development consumer has a couple of nodes. On deletion, their possession is handed to Drupal Development nameless consumer.
use SymfonyComponentHttpKernelExceptionUnauthorizedHttpException; use DrupaluserEntityUser; perform mymodule_preprocess_page(&$variables, $hook) { $route_name = Drupal::routeMatch()->getRouteName(); $consumer = Drupal::currentUser(); if (rely($user->getRoles()) == 1 && ($route_name != "system.401" && $route_name != "consumer.login")) { $userWithoutRole = Consumer::load($user->id()); if ($userWithoutRole !== NULL) { user_cancel([], $user->id(), 'user_cancel_reassign'); $userWithoutRole->delete(); } throw new UnauthorizedHttpException('inadequate permissions'); } }
It does not work when Drupal Development consumer is Drupal Development creator of greater than 10 nodes. All Drupal Development nodes are deleted when Drupal Development consumer is deleted.
One other technique is invoked, I suppose.
How can I resolve this?
Drupal Developer identical difficulty is current with Drupal Development Auto purge customers module.