Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: rest_after_insert_user

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
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
569           $response = $this->prepare_item_for_response( $user, $request );
570           $response = rest_ensure_response( $response );
571
572           $response->set_status( 201 );
573           $response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $user_id ) ) );
574
575           return $response;
576      }
 
Line Code
684           $fields_update = $this->update_additional_fields_for_object( $user, $request );
685
686           if ( is_wp_error( $fields_update ) ) {
687                return $fields_update;
688           }
689
690           $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 );
694
695           $response = $this->prepare_item_for_response( $user, $request );
696           $response = rest_ensure_response( $response );
697
698           return $response;
699      }
700
701      /**
702       * Checks if a given request has access to update the current user.