Make WordPress Core

Changeset 63672


Ignore:
Timestamp:
09/17/2026 05:39:44 PM (11 hours ago)
Author:
adamsilverstein
Message:

Posts, Post Types: Reject a supplied post ID on the create path in _wp_translate_postdata().

Props xknown, westonruter, jorbin, vortfu, batmoo, davidbinda, jeremyfelt.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/post.php

    r63497 r63672  
    2323        if ( empty( $post_data ) ) {
    2424                $post_data = &$_POST;
     25        }
     26
     27        /*
     28         * A raw `ID` on the create path (no `post_ID`) is an attempt to overwrite an
     29         * existing post while bypassing the per-post capability checks below, which only
     30         * run on the update path. Reject it outright: legitimate post creation never
     31         * carries an `ID`.
     32         */
     33        if ( ! $update && ! empty( $post_data['ID'] ) ) {
     34                if ( 'page' === $post_data['post_type'] ) {
     35                        return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) );
     36                } else {
     37                        return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) );
     38                }
    2539        }
    2640
Note: See TracChangeset for help on using the changeset viewer.