Support » Fixing WordPress » Can someone explain “Hooks” and “do_action” to me?

  • Resolved Johnny T

    (@johnny-t)


    Hi all,

    I spent a happy hour last night trying to de-bug my registration page. It ends up that the fault was due to my SimplePress installation (a brilliant plugin by the way – I’m not trying to denegrate it here at all). SimplePress required a Math question to be answered but my registration page wasn’t providing the answer. It was therefore silently killing all my registration attempts.

    Anyhoo… during my fault finding I came across this line of code:
    do_action('register_post', $user_login, $user_email, $errors);

    I naturally thought that “do_action” was passing the arguments $user_login, $user_email etc into a function called “register_post”. But there isn’t a register_post function?

    My bleary-eyed searches on the net seemed to suggest that “do_action” was something to do with “Hooks”.

    I’ve seen the term Hooks referred to a LOT during my work with WordPress but I don’t understand exactly what they are.

    So……..

    1) Could someone explain in laymans terms what “Hooks” are please?
    2) Could someone explain how to go about fault-finding on “do_action” statements? i.e. Do they call a function or are they indirectly calling a function? How do you trace through them to find where the code goes next?

    If you have any ideas on these questions or could shed any light on this at all it will be very much appreciated, not only by me, but by my rapidly thinning scalp!

    Thanks

    John 😉

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Can someone explain “Hooks” and “do_action” to me?’ is closed to new replies.