Make WordPress Core


Ignore:
Timestamp:
10/17/2018 11:19:02 AM (6 years ago)
Author:
danielbachhuber
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.
Fixes #42864.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

    r43445 r43737  
    556556        $request->set_param( 'context', 'edit' );
    557557
     558        /**
     559         * Fires after a user is completely created or updated via the REST API.
     560         *
     561         * @since 5.0.0
     562         *
     563         * @param WP_User         $user     Inserted or updated user object.
     564         * @param WP_REST_Request $request  Request object.
     565         * @param bool            $creating True when creating a user, false when updating.
     566         */
     567        do_action( 'rest_after_insert_user', $user, $request, true );
     568
    558569        $response = $this->prepare_item_for_response( $user, $request );
    559570        $response = rest_ensure_response( $response );
     
    678689
    679690        $request->set_param( 'context', 'edit' );
     691
     692        /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php */
     693        do_action( 'rest_after_insert_user', $user, $request, false );
    680694
    681695        $response = $this->prepare_item_for_response( $user, $request );
Note: See TracChangeset for help on using the changeset viewer.