WordPress.org

Make WordPress Core

Changeset 44967


Ignore:
Timestamp:
03/21/2019 08:11:29 PM (5 months ago)
Author:
SergeyBiryukov
Message:

Users: Introduce users_have_additional_content filter to indicate whether the users being deleted have additional content associated with them outside of the post_author and link_owner relationships.

Props garrett-eclipse, xkon, birgire.
Fixes #36860.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/users.php

    r44574 r44967  
    235235        }
    236236
    237         $users_have_content = false;
    238         if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
    239             $users_have_content = true;
    240         } elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
    241             $users_have_content = true;
     237        /**
     238         * Filters whether the users being deleted have additional content
     239         * associated with them outside of the `post_author` and `link_owner` relationships.
     240         *
     241         * @since 5.2.0
     242         *
     243         * @param boolean $users_have_additional_content Whether the users have additional content. Default false.
     244         * @param int[]   $userids                       Array of IDs for users being deleted.
     245         */
     246        $users_have_content = (bool) apply_filters( 'users_have_additional_content', false, $userids );
     247
     248        if ( ! $users_have_content ) {
     249            if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
     250                $users_have_content = true;
     251            } elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
     252                $users_have_content = true;
     253            }
    242254        }
    243255
Note: See TracChangeset for help on using the changeset viewer.