Problem/Motivation
Please add a README.md with general information about the module (may use the text from the module page in large parts) and add a code-example for bulk-updating the user setting to a certain route:
AI says this might work, but please test first, if it really does:
$new_route = 'TODO';
$user_storage = \Drupal::entityTypeManager()->getStorage('user');
// Get all users
$user_ids = $user_storage->getQuery()
->execute();
/** @var \Drupal\user\UserDataInterface $user_data */
$user_data = \Drupal::service('user.data');
foreach ($user_ids as $uid) {
$current = $user_data->get('user_preference_login_redirect', $uid, 'login_redirect_route');
if (empty($current)) {
$user_data->set('user_preference_login_redirect', $uid, 'login_redirect_route', $new_route);
}
}
return t('Default login redirect route "front.page" set for all users without a preference.');
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork user_preference_login_redirect-3561743
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
anybodyCode snippet is missing, afterwards that looks fine!
Comment #4
grevil commentedAdded a new Drush Command, put the parser inside a service and added a README. Please review!
Comment #5
grevil commentedHere is the MR: No idea whats going on with drupal gitlab:
https://git.drupalcode.org/project/user_preference_login_redirect/-/merg...
Comment #7
anybodyGREAT!
Comment #10
grevil commentedForgot to update the unit tests. Should be all green now! Fixed!