Commit a43a550160 for wordpress.org

commit a43a550160b2103290a29dd89bef664a620fcb8b
Author: johnbillion <johnbillion@git.wordpress.org>
Date:   Wed Nov 18 13:24:55 2026 +0000

    REST API: Restrict post and template author assignment to site members.

    Props jsnajdr, johnbillion, jeryj, xknown.

    Built from https://develop.svn.wordpress.org/trunk@65581


    git-svn-id: http://core.svn.wordpress.org/trunk@64654 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
index 0c24925ff9..a333b55845 100644
--- a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
+++ b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
@@ -1392,12 +1392,11 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {

 		// Author.
 		if ( ! empty( $schema['properties']['author'] ) && ! empty( $request['author'] ) ) {
-			$post_author = (int) $request['author'];
+			$post_author    = (int) $request['author'];
+			$current_author = isset( $existing_post ) ? (int) $existing_post->post_author : 0;

-			if ( get_current_user_id() !== $post_author ) {
-				$user_obj = get_userdata( $post_author );
-
-				if ( ! $user_obj ) {
+			if ( get_current_user_id() !== $post_author && $current_author !== $post_author ) {
+				if ( ! is_user_member_of_blog( $post_author ) ) {
 					return new WP_Error(
 						'rest_invalid_author',
 						__( 'Invalid author ID.' ),
diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php
index b2429f1f48..93e38bb095 100644
--- a/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php
+++ b/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php
@@ -640,12 +640,11 @@ class WP_REST_Templates_Controller extends WP_REST_Controller {
 		}

 		if ( ! empty( $request['author'] ) ) {
-			$post_author = (int) $request['author'];
+			$post_author    = (int) $request['author'];
+			$current_author = $template instanceof WP_Block_Template ? (int) $template->author : 0;

-			if ( get_current_user_id() !== $post_author ) {
-				$user_obj = get_userdata( $post_author );
-
-				if ( ! $user_obj ) {
+			if ( get_current_user_id() !== $post_author && $current_author !== $post_author ) {
+				if ( ! is_user_member_of_blog( $post_author ) ) {
 					return new WP_Error(
 						'rest_invalid_author',
 						__( 'Invalid author ID.' ),
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 28917730a9..757ab5f988 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.2-RC1-65580';
+$wp_version = '7.2-RC1-65581';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.