Make WordPress Core

Opened 5 years ago

Last modified 2 years ago

#36860 closed enhancement

Introduce filter for users_have_content within delete action of users.php — at Version 6

Reported by: garrett-eclipse Owned by: garrett-eclipse
Milestone: 5.2 Priority: normal
Severity: normal Version: 4.6
Component: Users Keywords: has-patch needs-testing has-dev-note
Focuses: administration Cc:

Description (last modified by garrett-eclipse)


I'd like to request an enhancement on the delete action for users.
Idea - https://wordpress.org/ideas/topic/introduce-filter-for-users_have_content-within-delete-action-of-usersphp?replies=1#post-30346

The addition of a filter for $users_have_content in the users.php

Proposed filter;

  * Filter the users_have_content, also known as the users have content flag, before use.
  * @since ###
  * @param boolean $users_have_content The flag for users have content.
$users_have_content = apply_filters( 'users_have_content', $users_have_content, $userids ) );

Allows for plugins to introduce reassign capabilities when their user relational data isn't handled through the posts_author or link_owner database checks.
Example: Co Authors Plus saves additional author information in taxonomy terms. If a co-author is removed currently no reassignment can be made. With the filter the userids can be checked for coauthor relationships so as to enable the reassign user ability.

Thank you

Change History (9)

#1 @lukecavanagh
5 years ago

Seems like a useful fix for users who are using Co-Authors Plus plugin on a live site.

3 years ago

Initial Concept

#2 @garrett-eclipse
3 years ago

  • Keywords has-patch 2nd-opinion needs-testing needs-unit-tests added
  • Owner set to garrett-eclipse
  • Status changed from new to accepted

Thanks @lukecavanagh

I've put together an initial patch for this but will require review and unit tests.

I placed the filter prior to the WordPress checks to avoid plugins suppressing them and possibly losing users content. If needed another filter can be added after to support suppression but I fear that may have negative consequences.

If you could review and help me with next steps I'd appreciate the help.


#3 @birgire
3 years ago

In 36860.diff I noticed a typo with an extra closing ).

3 years ago

Remove extra bracket

#4 @garrett-eclipse
3 years ago

  • Keywords 2nd-opinion removed

Thanks @birgire, Uploaded fix.

This ticket was mentioned in Slack in #core by garrett-eclipse. View the logs.

3 years ago

#6 @garrett-eclipse
3 years ago

  • Description modified (diff)
  • Milestone changed from Awaiting Review to 4.9.9

3 years ago

Wrap SQL checks in conditional to avoid unnecessary database calls

Note: See TracTickets for help on using tickets.