[wp-hackers] What's the best way of knowing which wordpress event to hook into?

Haluk Karamete halukkaramete at gmail.com
Fri Jan 18 21:08:55 UTC 2013


You are right. I should have thought about the do_actions.

I also found this which is pretty useful. Sharing for those who need it.

http://www.wprecipes.com/list-all-hooked-wordpress-functions

thanks for the pointer...

On Fri, Jan 18, 2013 at 12:44 PM, Dobri <dyordan1 at ramapo.edu> wrote:
> Hey there!
>
> Out of curiosity I checked and, if you look at the definition of the do_action function, you can see the following line:
>
> * @global array $wp_actions Increments the amount of times action was triggered.
>
> That's actually fairly obvious once you look at the code of the function itself, but whatever. Just a wild guess, you can probably hook to the shutdown hook and just save the value of this global array to database/flat file/whatever and then look at it later. Treat it like a hook log, no?
>
> On Fri, 18 Jan 2013, at 3:25 PM, Haluk Karamete wrote:
>
>> Good morning!
>>
>> Say, you wanted to carry out some action when you click on the publish
>> post button when creating a new post. For the sake of an example,
>> let's say you wanted an email to be automatically sent to somebody
>> everytime you create a post.
>>
>> The question is what's the best way to know which core functions are
>> available to hook into - to carry out the emailing.
>>
>> Or is it that, you kind of guess it - relying strictly on your
>> WordPress API memory? For example, you could think that since this
>> action has to do with creating a post, you should search for function
>> names in the plugin/actions codex page containing the word post in
>> them and then scan them thru to perhaps pick up items such as
>> wp_insert_post, wp_update_post, save_post, post_X, X_post etc etc? Is
>> this the norm?
>>
>> For this particular case, you will probably ending up with either
>> wp_insert_post or save_post. But my question is general. Is this the
>> right way to approach to the problem?
>>
>> Or.. is there another or more efficient way ( perhaps a plug in ) to
>> let me know which ( hookable) core functions have run in the current
>> or in the previous request? This way, I could get a definitive list of
>> all the related functions for me to choose from or read about which
>> are directly dealing with the current request that I'm interested in.
>> No more guess work...
>>
>> note that because of the header redirects, current request may not cut
>> it, you would need to be able to get a list of all hookable functions
>> in the previous request. ( the one that just has run before the
>> redirect code was encountered ).
>>
>> http://stackoverflow.com/questions/14405636/whats-the-best-way-of-knowing-which-wordpress-event-to-hook-into
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
> ~Dobri
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list