New answers tagged

1

$node->set('uid', 0); $node->save should have worked. Maybe you forgot to flush caches. To programmatically set the author to anonymous user on any entity you can call $entitiy->setOwnerId(0); and then $entity->save();, done. $entity->setOwnerId(0); $entity->save();


0

$currentUser = \Drupal::currentUser(); $query = \Drupal::entityQuery('node'); $query->condition('uid', $currentUser->id()); $author_nids=$query->execute();


0

For anyone looking for a D8 solution: Filename: YOUR_MODULE.routing.yml YOUR_MODULE.user_edit: path: '/user/{user}/edit' defaults: _entity_form: 'user.default' _title_callback: 'Drupal\user\Controller\UserController::userTitle' requirements: _entity_access: user.update user: \d+ options: _admin_route: FALSE


1

user_cancel() is run in a batch. This means that either it's called in a form, or batch_process() needs to be called after it. For example, this is the code used from UserController::confirmCancel(). $edit = [ 'user_cancel_notify' => isset($account_data['cancel_notify']) ? $account_data['cancel_notify'] : $this->config('user.settings')->get('...


Top 50 recent answers are included