Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

There's a function attached to a set of actions, like this:

add_action('some_tag', 'the_function');

function the_function($maybe_some_vars){
  // ...
}

Is it possible to find out the action name ("some_tag") within the_function?

The reason I'm asking, is that I'm attaching the function to multiple actions (some of them custom, some belong to WP like the_content). The code that executes within the function depends on knowing the name of the action.

I did manage to get it using debug_backtrace(), but I'm pretty sure that's not a very reliable way.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Simple: current_filter(); (link to plugin.php) or global $wp_current_filter;.

share|improve this answer
    
Thanks, I knew about it and didn't think about using it! :) –  onetrickpony May 6 '12 at 18:58
    
n/p. We all got moments where we simply forget about the obvious stuff. :) –  kaiser May 6 '12 at 18:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.