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

WordPress Trac noreply at wordpress.org
Wed Mar 20 09:48:41 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 2nd-opinion  |     Focuses:
  dev-feedback                                   |  administration
-------------------------------------------------+-------------------------

Comment (by birgire):

 If the approach in [attachment:"36860.5.diff"] is preferred, then I wonder
 if another filter name would be beneficial:

 like {{{users_have_custom_content}}}, {{{users_have_additional_content}}}
 or something that describes that this is in addition to authored posts or
 owned links, instead of the general {{{users_have_content}}} name.

 So if the filter's output is false then {{{$users_have_content}}} would be
 determined from the current post author or link owner checks.

 If the filter's output is true then {{{$users_have_content}}} would be
 true and the current post author or link owner checks would be skipped.

 Here's an example:

 {{{
  */
 $users_have_custom_content = (bool) apply_filters(
 'users_have_custom_content', false, $userids ) );

 $users_have_content = false;

 if ( $users_have_custom_content ) {
         $users_have_content = true;
 } else {
         if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE
 post_author IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
                 $users_have_content = true;
         } elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links}
 WHERE link_owner IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
                 $users_have_content = true;
         }
 }
 }}}

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


More information about the wp-trac mailing list