From 4060c68f85fc090a9feadd619aaf58a88642d3c9 Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Wed, 9 Nov 2016 01:35:30 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@39177 git-svn-id: http://core.svn.wordpress.org/trunk@39117 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../rest-api/endpoints/class-wp-rest-users-controller.php | 6 ++++++ wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php index 08fc183167..949a66863d 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php @@ -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'] ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 2355c6f9c7..7dabe9ab9b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-beta2-39176'; +$wp_version = '4.7-beta2-39177'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.