[wp-trac] [WordPress Trac] #36860: Introduce filter for users_have_content within delete action of users.php

WordPress Trac noreply at wordpress.org
Tue Mar 19 18:00:39 UTC 2019


#36860: Introduce filter for users_have_content within delete action of users.php
-------------------------------------+------------------------------
 Reporter:  garrett-eclipse          |       Owner:  garrett-eclipse
     Type:  enhancement              |      Status:  accepted
 Priority:  normal                   |   Milestone:  5.2
Component:  Users                    |     Version:  4.6
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:  administration
-------------------------------------+------------------------------

Comment (by birgire):

 Thanks @garrett-eclipse for that information and it's informative to see
 how plugins are handling it.

 It looks like the plugin is using

 {{{
 add_action( 'delete_user',  array( $this, 'delete_user_action' ) );
 }}}

 and then using

 {{{
 $reassign_id = isset( $_POST['reassign_user'] ) ? absint(
 $_POST['reassign_user'] ) : false;
 }}}

 I've not used this plugin and don't know it's code base, but just from a
 very quick skimming I wonder why it's not using the second input
 {{{$reassign}}} argument of the {{{delete_user}}} action:

 https://core.trac.wordpress.org/browser/tags/5.1.1/src/wp-
 admin/includes/user.php#L363

 instead of looking into the global {{{$_POST}}} value? But I guess there's
 a good reason for that.


 One thing that might be confusing with the current patch
 [attachment:"36860.5.diff"] is that if we use e.g.:

 {{{
 add_filter( 'users_have_content', '__return_false' );
 }}}

 The developer might think it's being overriden by the filter, but we still
 get the UI for reassigning/removing user data, even if the deleted user is
 post author or link owner.

 Another approach, if we want to allow the filter to control the UI both
 ways, is to have the default filter value as {{{null}}} and only run the
 {{{post_author}}} and {{{link_owner}}} queries for {{{null}}}. That way
 the boolean value of the filter can be used to turn it on/off.

 Do you see any reason to know that the user is being deleted from this UI,
 compared to e.g. other {{{wp_delete_user()}}} calls elsewhere?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/36860#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list