mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@39177 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -434,6 +434,8 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
|
||||
if ( is_wp_error( $user_id ) ) {
|
||||
return $user_id;
|
||||
}
|
||||
|
||||
add_user_to_blog( get_site()->id, $user_id, '' );
|
||||
} else {
|
||||
$user_id = wp_insert_user( $user );
|
||||
|
||||
@@ -558,6 +560,10 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
|
||||
|
||||
$user = get_user_by( 'id', $id );
|
||||
|
||||
if ( is_multisite() && ! is_user_member_of_blog( $id ) ) {
|
||||
add_user_to_blog( get_current_blog_id(), $id, '' );
|
||||
}
|
||||
|
||||
if ( ! empty( $request['roles'] ) ) {
|
||||
array_map( array( $user, 'add_role' ), $request['roles'] );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user