Problem/Motivation

When cancelling an account, the only option to reassign content is to the anonymous account.

Proposed resolution

Add the ability to specify a user content will be reassigned.

User interface changes

tbd

Data model changes

tbd

Original report by hctom

Hi @all,

I'm not sure, if I'm too late for the API changes feature request, but I think it would be quite useful to tweak the "Delete the account and make all content belong to the Anonymous user." method for cancelled accounts.

It would be great to have an autocomplete field, too choose the user the content is reassigned to instead of always using the anonymous user. If the field is left empty, a default value should be used. This may either be the anonymous or a configurable setting value should be available for this.

Of course, this tweak for method may only be available to privileged users (e.g. with "Administer users" permission or even an own permission for this selection), so non-admin users with the "Select method for cancelling own account" may not reassign contents to other users by default (as this may be abused).

With this tweak site administrators may be able to set up a special account like "Deleted person" to reassign the content to. The may also reassign contents to the correct user, when two accounts need to be merged by cancelling one of them.

The corresponding uid may be transferred to hook_user_cancel() via the $edit parameter, so there is no need to change the hook's function signature. Only the performed queries need to be altered slightly to use the passed uid instead of 0.

So... what do you think about this proposal?

I'd appreciate, getting feedback for this.

Thanx in advance & cheers

hctom

Issue fork drupal-606824

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

mrfelton’s picture

subs.

ilo’s picture

Just to mention that with current user cancel API it can be done in a contrib module..

damien tournoud’s picture

Version: 7.x-dev » 8.x-dev

Drupal 7 has long been featured frozen.

jhedstrom’s picture

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

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

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now 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.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now 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.

dpi’s picture

Title: Enable user defined reassign target when a user account is cancelled » Allow admins to specify which account the content for a cancelled user is assigned
Issue summary: View changes

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

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now 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.

jieyyal’s picture

Hi @hctom

There is already a contrib module available for D7.
https://www.drupal.org/project/move_user

Port to Drupal 8 is almost done.
https://www.drupal.org/node/2693353

Check more detail on github.
https://github.com/ciandt-china-dev/hackathon-drupal8-move_user

Thanks

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

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now 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.

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

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now 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.

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.

dpi’s picture

Issue tags: -cancel +user cancellatiom
dpi’s picture

Issue tags: -user cancellatiom +user cancellation
dpi’s picture

I think this issue would also solve the feature request to merge users. Per #2040139: Allow users to be merged

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.

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.

anybody’s picture

I really really don't like Wordpress, but they have this option! And it's VERY handy if for example an employee leaves the company and another one takes his position, which isn't that untypical...

So +1 for an option to allow selecting a user to reassign contents when deleting an account instead of removing the user (assign to Guest). Overdue since Drupal 6, I guess? ;) (no offense, I didn't implement it either ;))

Also agree with #16, at least for all affected contents!

As VBO for example already has options to batch (re)assign entities ownership, it might make sense to generalize these functionalities into 10.x core?

I know this by far isn't as simple as it sounds, but I guess it's kind of base functionality for a mature CMS?

anybody’s picture

Issue tags: -D7UX usability

Removing Drupal 7 tag. @dpi should we perhaps change the Core version to 10.x? Would it make sense to discuss this in core team then?

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.

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.

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

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

euk’s picture

+1 for this feature. Going to look at it.

euk’s picture

euk’s picture

There is a module that attempts to solve this - https://www.drupal.org/project/user_delete_reassign, but it was not updated for a long time, has a few bugs reported and doesn't work for me with the view bulk op out of the box. Another considerations to be made - this should work with Workbench Access and similar modules. For that there should be a hook/event and validation system which would allow to alter username suggestions or validate new owner content access rights.

euk’s picture

Assigned: Unassigned » euk

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

ramprassad’s picture

Assigned: euk » ramprassad

ramprassad’s picture

I have created an MR 10488 for the changes related to this functionality. Please check

ramprassad’s picture

Status: Active » Needs review
ramprassad’s picture

Assigned: ramprassad » Unassigned

Unassigning as the MR is raised

euk’s picture

@ramprassad, you bit me to it =) Though I am currently working on creating a D10 patch, and there are a few differences anyway. I looked at your PR and left a couple of comments. I also have a few suggestions:

  1. I do not recommend storing a default UID for this new cancellation method in the configs: developers then have to maintain this config, while most of the time admins probably want to reassign content to different users (based on my experience with medium to large sites), therefore making this default setting irrelevant and annoying.
  2. Added to the above - if the account matching the default UID has been disabled/deleted - you would have to update the config and also might have to deal with consequences of assigning content to deleted/disabled users.
  3. When reassigning content, you should account for editorial permissions - is the new user able to edit content? The simplest way to check that the content belonging to the account being deleted can be edited by the new users is to compare roles and make necessary adjustment to the account suggestions in the entity autocomplete.
  4. Same as above should be also considered for multiple accounts being deleted in bulk - here you'd want the new user have all the roles the deleted users had, or let the admins know what the consequences are if there are some mismatches.
  5. There should be a hook/event allowing to alter user selection - some modules like Workbench Access have their own content permissions model and need to be able to intervene.

I am including the above into my D10 patch. Hopefully will have it by EOD.

euk’s picture

Status: Needs review » Needs work

euk changed the visibility of the branch 606824-allow-admins-to to hidden.

euk’s picture

While D10.3.x. merge fails (specifically - unit test, though it shows 100% success rate), here is the patch for D10.3.x - should work with 10.3.6 and up, till 10.3.10 at least.

euk’s picture

Adding updated patch for 10.3.x

euk’s picture

euk’s picture

StatusFileSize
new13.19 KB

A few more updates to the 10.3.x patch.

euk’s picture

Minor fix to the 1.3.x. patch.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.