Make WordPress Core

Changeset 47173


Ignore:
Timestamp:
02/04/2020 07:34:27 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Users: In remove_user_from_blog():

  • Change default value of the $blog_id parameter to match the documented type.
  • Change the type of the $reassign parameter for consistency with $user_id and $blog_id.
  • Add documentation for the return value.

See #49361.

Location:
trunk/src
Files:
2 edited

Legend:

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

    r47122 r47173  
    159159
    160160                        if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][ $blogid ][ $id ] ) {
    161                             remove_user_from_blog( $id, $blogid, $user_id );
     161                            remove_user_from_blog( $id, $blogid, (int) $user_id );
    162162                        } else {
    163163                            remove_user_from_blog( $id, $blogid );
  • trunk/src/wp-includes/ms-functions.php

    r47122 r47173  
    235235 * @global wpdb $wpdb WordPress database abstraction object.
    236236 *
    237  * @param int    $user_id  ID of the user you're removing.
    238  * @param int    $blog_id  ID of the blog you're removing the user from.
    239  * @param string $reassign Optional. A user to whom to reassign posts.
    240  * @return true|WP_Error
    241  */
    242 function remove_user_from_blog( $user_id, $blog_id = '', $reassign = '' ) {
     237 * @param int $user_id  ID of the user you're removing.
     238 * @param int $blog_id  Optional. ID of the blog you're removing the user from. Default 0.
     239 * @param int $reassign Optional. ID of the user to whom to reassign posts. Default 0.
     240 * @return true|WP_Error True on success or a WP_Error object if the user doesn't exist.
     241 */
     242function remove_user_from_blog( $user_id, $blog_id = 0, $reassign = 0 ) {
    243243    global $wpdb;
     244
    244245    switch_to_blog( $blog_id );
    245246    $user_id = (int) $user_id;
     247
    246248    /**
    247249     * Fires before a user is removed from a site.
     
    254256    do_action( 'remove_user_from_blog', $user_id, $blog_id );
    255257
    256     // If being removed from the primary blog, set a new primary if the user is assigned
    257     // to multiple blogs.
     258    // If being removed from the primary blog, set a new primary
     259    // if the user is assigned to multiple blogs.
    258260    $primary_blog = get_user_meta( $user_id, 'primary_blog', true );
    259261    if ( $primary_blog == $blog_id ) {
     
    289291    }
    290292
    291     if ( $reassign != '' ) {
     293    if ( $reassign ) {
    292294        $reassign = (int) $reassign;
    293295        $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $user_id ) );
Note: See TracChangeset for help on using the changeset viewer.