Action hook 'rest_after_insert_attachment'

in WP Core File wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php at line 479

View Source

rest_after_insert_attachment

Action Hook
Description
Updates a single attachment.

Hook Information

File Location wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php View on GitHub
Hook Type Action
Line Number 479

Hook Parameters

Type Name Description
WP_REST_Request $request Full details about the request.

Usage Examples

Basic Usage
<?php
// Hook into rest_after_insert_attachment
add_action('rest_after_insert_attachment', 'my_custom_function', 10, 1);

function my_custom_function($request) {
    // Your custom code here
}

Source Code Context

wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php:479 - How this hook is used in WordPress core
<?php
 474  		}
 475  
 476  		$request->set_param( 'context', 'edit' );
 477  
 478  		/** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php */
 479  		do_action( 'rest_after_insert_attachment', $attachment, $request, false );
 480  
 481  		wp_after_insert_post( $attachment, true, $attachment_before );
 482  
 483  		$response = $this->prepare_item_for_response( $attachment, $request );
 484  		$response = rest_ensure_response( $response );

PHP Documentation

<?php
/**
	 * Updates a single attachment.
	 *
	 * @since 4.7.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error Response object on success, WP_Error object on failure.
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 1
  • File: wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
Related Hooks

Related hooks will be displayed here in future updates.