New answers tagged


It worked in Drupal 8 use Symfony\Component\HttpFoundation\RedirectResponse; function YOUR_MODULE_user_update($account) { $uid = \Drupal::currentUser()->id(); $url = '/u/' . $uid; $response = new RedirectResponse($url); $request = \Drupal::request(); $request->getSession()->save(); $response->prepare($request); \Drupal::service('...


I think you're asking, "How can I create a translated string 'Send a private message to @username' where @username is replaced with the name of the user currently being viewed?" If you're viewing the user's page, you can do this like: // Get the user object currently being viewed from the route parameters. $user = \Drupal::routeMatch()->...


The Allowed Languages module makes it possible to set restrictions on which content a user can edit based on language. Once installed against each user profile you can check which languages the user can edit as shown below.


This issue appears to have been resolved in: which was merged into core as of 8.1.4. In order to preserve pre-hashed passwords, add the following to your migration YAML file: destination: plugin: entity:user pre_hashed: true


If you have the user entity, it's already loaded, and you can get the ID from it. Drupal 7 $user->uid Drupal 8 and later $user->id()

Top 50 recent answers are included