Make WordPress Core


Ignore:
Timestamp:
12/12/2018 09:11:27 PM (7 years ago)
Author:
desrosj
Message:

REST API: Fire actions after items are completely updated/inserted.

The existing rest_insert_* actions are fired before meta and additional fields are updated. These new rest_after_* actions fire after all write operations have completed.

Props timothyblynjacobs, danielbachhuber.

Merges [43737] to trunk.

Fixes #42864.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

    r43571 r43987  
    567567        $request->set_param( 'context', 'edit' );
    568568
     569        /**
     570         * Fires after a user is completely created or updated via the REST API.
     571         *
     572         * @since 5.0.0
     573         *
     574         * @param WP_User         $user     Inserted or updated user object.
     575         * @param WP_REST_Request $request  Request object.
     576         * @param bool            $creating True when creating a user, false when updating.
     577         */
     578        do_action( 'rest_after_insert_user', $user, $request, true );
     579
    569580        $response = $this->prepare_item_for_response( $user, $request );
    570581        $response = rest_ensure_response( $response );
     
    689700
    690701        $request->set_param( 'context', 'edit' );
     702
     703        /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php */
     704        do_action( 'rest_after_insert_user', $user, $request, false );
    691705
    692706        $response = $this->prepare_item_for_response( $user, $request );
Note: See TracChangeset for help on using the changeset viewer.