In some cases, you do not know a user's account ID, but you want them to edit their user account. Having user/edit setup to edit the currently logged in user's account would help with sending users to the right edit page without needing to know their User ID. If not logged in, it would present them with the user login, and then shoot them to the edit page.

Places this might be helpful:

  • Emails
  • Help documentation to edit the user account
  • etc

Comments

danillonunes’s picture

I would like to see this feature too. Sometimes I miss an user/edit path to use in a custom menu.

danillonunes’s picture

Status: Active » Needs review
StatusFileSize
new846 bytes

I made a patch against HEAD. I don't know if it is the best way to do it, but it's the simpler that I could do for now.

Maybe someone can improve this (like, if both user/%user/edit and user/edit runs the same "wrapper" function, that checks if the uid has been passed into the url and, if not, redirect to the correct path with the uid appended. It would be more "consistent" IMHO).

sebyoga’s picture

Hello,

If you wan't, temporary, you can use the module "me" when you don't not know a user's account ID.

Example : user/me/edit

Best regards,

Sébastien

kscheirer’s picture

StatusFileSize
new875 bytes

Still seems useful to me, rerolled patch against HEAD.

sammuell’s picture

#4: user-user_edit-1057570-4.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, user-user_edit-1057570-4.patch, failed testing.

sammuell’s picture

StatusFileSize
new1.54 KB

I just implemented this feature in a custom module (for d7) and thought that this is missing in core. After a quick search I found this issue.
My version also includes correct handling for the destination parameter.

sammuell’s picture

Status: Needs work » Needs review

Forgot to change issue status...

sushantpaste’s picture

Issue summary: View changes

Needs to create patch according to Drupal 8 Menu routing system.
Drupal 8 routing

sushantpaste’s picture

Status: Needs review » Needs work
nitesh pawar’s picture

Status: Needs work » Needs review
StatusFileSize
new1.97 KB

created patch according to Drupal 8 Menu routing system.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

deg’s picture

Issue tags: +Usability

I believe this would be a very useful addition and have client requests for it. Attempting to apply the patch to a dev site returned a rejected hunk at @@ -15,7 +15,7 @@, likely due to additional ‘use Symfony’ includes in the latest version of Drupal. I manually added the rejected hunk and it works wonderfully.

I'm glad this is redirecting to the canonical user/{uid}/edit as far as I can tell. This patch does not, however, redirect other links such as user/{uid}/shortcuts, which might be additional functionality that could be helpful.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

MaskOta’s picture

Status: Needs review » Needs work

I like this functionality but i think it should be handled like the '/user' route where we just redirect to the entity.user.canonical with the current user id:

public function userPage() {
    return $this->redirect('entity.user.canonical', ['user' => $this->currentUser()->id()]);
  }

so something like:

public function userEditPage() {
    return $this->redirect('entity.user.edit_form', ['user' => $this->currentUser()->id()]);
  }
artusamak’s picture

Version: 8.5.x-dev » 8.6.x-dev
Status: Needs work » Needs review
Issue tags: +DevDaysLisbon
StatusFileSize
new2.64 KB

Here is a patch attempt for that following the strategy suggested in #18.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ranjith_kumar_k_u’s picture

StatusFileSize
new2.68 KB

Re-rolled the last patch for 9.3

ranjith_kumar_k_u’s picture

StatusFileSize
new2.68 KB

Fixed custom commands fail

mitthukumawat’s picture

StatusFileSize
new152.1 KB

I have applied the patch #27 cleanly but I can still see the dependency on user id while editing the currently logged in user.
The path is showing as user/{userid}/edit. But if I enter the url user/edit manually, it redirected this again to user/{userid}/edit. I think it should be user/edit when edit the currently logged in user.

Steps I have followed for testing :

  • Created new test user.
  • Applied the patch #27 and clear the drupal cache.
  • Login to the new test user and clicked on Edit tab.

.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

sonam.chaturvedi’s picture

Patch #27 applied successfully on 9.5.x-dev with 2 offsets.

Test Result:
Same as #28. User is able to access 'user/edit' manually and is redirected to user/{userid}/edit

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

kristen pol’s picture

Status: Needs review » Needs work

Thanks for the patches and updates.

@ranjith_kumar_k_u Please include an interdiff when making changes (I see you fixed some typos): https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa...

Since the typos were fixed, I just have some nitpicks and one naming convention thing.

  1. +++ b/core/modules/user/src/Controller/UserController.php
    @@ -262,6 +262,21 @@ public function userPage() {
    +   *   Returns a redirect to the profile edition form of the currently
    +   *   logged in user.
    

    The wrapping isn't quite right but, rather than fixing that, maybe we can just get it down to one line, e.g.

    Returns a redirect for the current user's profile edit page.

    (Note, I checked and "profile page" is used more than "account page" in the code.)

  2. +++ b/core/modules/user/tests/src/Functional/UserEditedOwnAccountTest.php
    @@ -33,4 +33,21 @@ public function testUserEditedOwnAccount() {
       }
     
    +  public function testUserAccessEditAccountShortcut() {
    +    // Verify that the route is not accessible for anonymous users.
    

    Missing doc block.

  3. +++ b/core/modules/user/tests/src/Functional/UserEditedOwnAccountTest.php
    @@ -33,4 +33,21 @@ public function testUserEditedOwnAccount() {
    +    // Verify that the redirected route is still the edit page of the logged in
    +    // user.
    

    Since this is wrapping with one dangling word, consider rewording to make it one line and making it consistent with above changes, e.g.

    Verify the redirected route is still the current user's profile edit page.

  4. +++ b/core/modules/user/tests/src/Functional/UserEditedOwnAccountTest.php
    @@ -33,4 +33,21 @@ public function testUserEditedOwnAccount() {
    +    $this->assertEquals($current_url, $this->baseUrl . '/user/' . $account->id() . '/edit', 'The user access its account edition page.');
    

    Wording is a bit awkward and "account edition page" is not commonly used, so consider rewording and making it consistent with above changes, e.g.

    The current url is the current user's profile edit page.

Lastly, I'm not sure about using "shortcut" in the naming since shortcuts are a thing in core. Maybe we call it a redirect? e.g.

user.edit_redirect

userEditRedirect

pooja saraah’s picture

Assigned: Unassigned » pooja saraah
pooja saraah’s picture

StatusFileSize
new2.65 KB
new3.11 KB

Thanks for your suggestions @Kristen Pol
Addressed the comment #33
Attached patch against Drupal 10.1.x
Attached reroll patch.

pooja saraah’s picture

Assigned: pooja saraah » Unassigned
acbramley’s picture

Status: Needs work » Needs review
StatusFileSize
new1.66 KB
new1.25 KB

Swapped to use the existing redirect callback.

dpi’s picture

Status: Needs review » Closed (duplicate)
Related issues: +#3168624: Add 'user/edit' route

It looks like another issue duplicating this issue was already merged: #3168624: Add 'user/edit' route

The other was created in 2020 and merged 2 months ago into 9.5.x and 10.x branches.

The new route is available at user.edit, see also the change record: https://www.drupal.org/node/3313603