Support » Plugins » Understanding difference between do_action & add_action

  • Hi all,

    I am having some trouble understanding the exact difference between the do_action and add_action functions. I’ve searched google and these forums, still am confused. Codex does not help me either.

    I understand the add_action function for writing a plugin that does something at a certain point in the WordPress flow using a call back function.

    But what is do_action? I see no callback function or anything when these are used. I guess I don’t get the exact difference between the two and moreso the point or use of do_action when writing a custom plugin?

    Help from someone with more working knowledge than me explain the simple difference I am not able to grasp?

Viewing 2 replies - 1 through 2 (of 2 total)
  • esmi


    Forum Moderator

    add_action allows you to hook a function on to a pre-existing action. do_action allows you to create a new action. A plugin might use do_action to create its own custom “hook” and then add functions to that hook in various scripts via add_action.

    manoj insa


    hi ,

    i am new in wordpress, i created one site in it. Now i want to create my plugin , so please tell me,, how i accomplished this..anyone help me Please !

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Understanding difference between do_action & add_action’ is closed to new replies.