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

Command icon 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

anybody created an issue. See original summary.

grevil made their first commit to this issue’s fork.

anybody’s picture

Status: Active » Needs work

Code snippet is missing, afterwards that looks fine!

grevil’s picture

Assigned: grevil » Unassigned
Status: Needs work » Needs review

Added a new Drush Command, put the parser inside a service and added a README. Please review!

grevil’s picture

Here is the MR: No idea whats going on with drupal gitlab:
https://git.drupalcode.org/project/user_preference_login_redirect/-/merg...

anybody’s picture

Status: Needs review » Reviewed & tested by the community

GREAT!

  • anybody committed a97ba3aa on 1.x authored by grevil
    feat: #3561743 Add a README.md and add an example for bulk-updating user...

  • grevil committed e354799c on 1.x
    Related to issue #3561743, fix Unit Tests
    
grevil’s picture

Status: Reviewed & tested by the community » Fixed

Forgot to update the unit tests. Should be all green now! Fixed!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.