Action hook 'post_action_{$action}'

in WP Core File wp-admin/post.php at line 363

View Source

post_action_{$action}

Action Hook
Description
Fires for a given custom post action request. The dynamic portion of the hook name, `$action`, refers to the custom post action.

Hook Information

File Location wp-admin/post.php View on GitHub
Hook Type Action
Line Number 363

Hook Parameters

Type Name Description
int $post_id Post ID sent with the request.

Usage Examples

Basic Usage
<?php
// Hook into post_action_{$action}
add_action('post_action_{$action}', 'my_custom_function', 10, 1);

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

Source Code Context

wp-admin/post.php:363 - How this hook is used in WordPress core
<?php
 358  		 *
 359  		 * @since 4.6.0
 360  		 *
 361  		 * @param int $post_id Post ID sent with the request.
 362  		 */
 363  		do_action( "post_action_{$action}", $post_id );
 364  
 365  		wp_redirect( admin_url( 'edit.php' ) );
 366  		exit;
 367  } // End switch.
 368  

PHP Documentation

<?php
/**
		 * Fires for a given custom post action request.
		 *
		 * The dynamic portion of the hook name, `$action`, refers to the custom post action.
		 *
		 * @since 4.6.0
		 *
		 * @param int $post_id Post ID sent with the request.
		 */
Quick Info
  • Hook Type: Action
  • Parameters: 1
  • File: wp-admin/post.php
Related Hooks

Related hooks will be displayed here in future updates.