Title: WP_CLI::do_hook()
Published: June 12, 2025
Last modified: June 1, 2026

---

# WP_CLI::do_hook()

## In this article

 * [Usage](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-do-hook/?output_format=md#usage)
 * [Notes](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-do-hook/?output_format=md#notes)
 * [Related](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-do-hook/?output_format=md#related)

[↑ Back to top](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-do-hook/?output_format=md#wp--skip-link--target)

Execute callbacks registered to a given hook.

---

## 󠀁[Usage](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-do-hook/?output_format=md#usage)󠁿

    ```
    WP_CLI::do_hook( $when, $args )
    ```

 **$when** (string) Identifier for the hook.
 **…$args** (mixed) Optional. Arguments
that will be passed onto the callback provided by `WP_CLI::add_hook()`. **@return**(
null|mixed) the first optional argument if optional<br /> arguments were passed,
otherwise returns null.

---

## 󠀁[Notes](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-do-hook/?output_format=md#notes)󠁿

See `WP_CLI::add_hook()` for details on WP-CLIWP-CLI WP-CLI is the Command Line 
Interface for WordPress, used to do administrative and development tasks in a programmatic
way. The project page is [http://wp-cli.org/](http://wp-cli.org/) [https://make.wordpress.org/cli/](https://make.wordpress.org/cli/)’
s internal hook system.
 Commands can provide and call their own hooksHooks In WordPress
theme and development, hooks are functions that can be applied to an action or a
Filter in WordPress. Actions are functions performed when a certain event occurs
in WordPress. Filters allow you to modify certain functions. Arguments used to hook
both filters and actions look the same..

_Internal APIAPI An API or Application Programming Interface is a software intermediary
that allows programs to interact with each other and share data in limited, clearly
defined ways. documentation is generated from the WP-CLI codebase on every release.
To suggest improvements, please submit a pull request._

---

## 󠀁[Related](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-do-hook/?output_format=md#related)󠁿

 * **[WP_CLI::add_hook()](https://make.wordpress.org/cli/handbook/internal-api/wp-cli-add-hook/)**–
   Schedule a callback to be executed at a certain point.
 * **[WP_CLI::add_wp_hook()](https://make.wordpress.org/cli/handbook/internal-api/wp-cli-add-wp-hook/)**–
   Add a callback to a WordPress action or filterFilter Filters are one of the two
   types of Hooks [https://codex.wordpress.org/Plugin_API/Hooks](https://codex.wordpress.org/Plugin_API/Hooks).
   They provide a way for functions to modify data of other functions. They are 
   the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated
   manner, and should never have side effects such as affecting global variables
   and output..
 * **[WP_CLI::add_command()](https://make.wordpress.org/cli/handbook/internal-api/wp-cli-add-command/)**–
   Register a command to WP-CLI.

First published

June 12, 2025

Last updated

June 1, 2026

Edit article

[ Improve it on GitHub: [article_title] ](https://github.com/wp-cli/handbook/edit/main/internal-api/wp-cli-do-hook.md)

Changelog

[ See list of changes: [article_title] ](https://github.com/wp-cli/handbook/commits/main/internal-api/wp-cli-do-hook.md)

[  Previous: WP_CLI::debug()](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-debug/)

[  Next: WP_CLI::error()](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-error/)