WordPress.org

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/doing action

Description

Checks to see if an action is currently being executed.

Usage

 <?php doing_action($action); ?>

Parameters

$action 
(string) (optional) The name of the action to check for, if omitted will check for any action being performed

Return Values

(boolean) 
Returns true if $action is being executed.

Example

To check whether the 'save_post' action is being executed you could write something similar to this:

 if(doing_action('save_post')){
   //Do Something Here
 }

To check if any action is being executed you could write something like this:

 if(doing_action()){
   //Do Something Here
 }

Sources

doing_action() is located in wp-includes/plugin.php

Related

Actions: add_action(), do_action(), has_action(), did_action(), remove_action()

This article is marked as in need of editing. You can help Codex by editing it.
Category:Functions