Make WordPress Core


Ignore:
Timestamp:
11/09/2016 01:34:56 AM (8 years ago)
Author:
rmccue
Message:

REST API: Fire correct hooks when creating users on multiste.

add_user_to_blog() is now called, ensuring the correct hooks are called, along with setting the primary blog and clearing relevant caches.

Props jeremyfelt.
Fixes #38526.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

    r39169 r39177  
    435435                return $user_id;
    436436            }
     437
     438            add_user_to_blog( get_site()->id, $user_id, '' );
    437439        } else {
    438440            $user_id = wp_insert_user( $user );
     
    558560
    559561        $user = get_user_by( 'id', $id );
     562
     563        if ( is_multisite() && ! is_user_member_of_blog( $id ) ) {
     564            add_user_to_blog( get_current_blog_id(), $id, '' );
     565        }
    560566
    561567        if ( ! empty( $request['roles'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.