WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/13/2018 04:23:35 AM (19 months ago)
Author:
pento
Message:

REST API: Tweak permission checks for taxonomy and term endpoints

To match behaviour in the Classic Editor, we need to slightly loosen permissions on taxonomy and term endpoints. This allows users to create terms to assign to a post that they're editing.

Props danielbachhuber.
Fixes #44096.

File:
1 edited

Legend:

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

    r43087 r43440  
    381381
    382382        $taxonomy_obj = get_taxonomy( $this->taxonomy );
    383         if ( ! current_user_can( $taxonomy_obj->cap->edit_terms ) ) {
     383        if ( ( is_taxonomy_hierarchical( $this->taxonomy )
     384                && ! current_user_can( $taxonomy_obj->cap->edit_terms ) )
     385            || ( ! is_taxonomy_hierarchical( $this->taxonomy )
     386                && ! current_user_can( $taxonomy_obj->cap->assign_terms ) ) ) {
    384387            return new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to create new terms.' ), array( 'status' => rest_authorization_required_code() ) );
    385388        }
Note: See TracChangeset for help on using the changeset viewer.