Back to Top

An Introduction to WordPress Action Hooks

actionhook in wordpress

WordPress provide functionality of action hook with which you can create your own action hook too.you can create new action hooks by calling do_action() function and just need to specify the name of the new hook as $tag parameter.Whereas add_action() is used to hooks a function on to a specific action.

SYNTAX for do_action

Parameters

$tag is the name of the action to be executed.
$arg is an optional argument which are passed on to the functions hooked to the action.

SYNTAX for add_action

Here is add_action, same like do_action $tag is the name of the action to be executed.Next argument is the name of the function to add for an action.The third argument defines the priority of code and the fourth argument is for a number of argument in the function.

Here in an example, going to show how to create an action hook that customize the login functionality just before the user logged into the dashboard.

First of,place below code into the wp-login.php file after post request for a form.

Next is use the function, which we can put in the functions.php of the theme to add an action for the login

Thanks for reading and feel free to share your thoughts! Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Share:
Share on Facebook0

Share on LinkedIn0Tweet about this on TwitterShare on Google+0Buffer this pageDigg thisShare on Reddit0

Comments (5)

  1. Article writing is also a excitement, if you be
    acquainted with after that you can write otherwise it is
    complex to write.

  2. Hi!
    Thanks for the desciption for 4 columns.
    In Step 3. Which one file do i need to add that code?
    footer.php or function.php or sidebar.php?

    Thanks
    Roland

  3. It is visible that wrote is acquainted with these issues and knows how to present it in a way easily understood for a greenhorn.
    I admit that I”m very interested in this entry despite the fact that I”m not much interested in this subject-matter.

  4. An fascinating dialogue is price comment. I feel that you need to write extra on this topic, it might not be a taboo subject but generally people are not enough to talk on such topics. To the next. Cheers

  5. Mcgoogan says:

    Wow, incredible weblog structure! How long have you been running a blog for? you created running a blog look simple. The entire look of your website is magnificent, neatly as the content material!

Leave a Reply

Your email address will not be published. Required fields are marked *

Most Popular Posts

How to backup MySQL database in PHP

Posted on 4 years ago

Bhumi

How to use Git init command

Posted on 2 months ago

Bhumi

Inheritance in object-oriented PHP

Posted on 8 months ago

Bhumi

How to Set the Time Zone in Modx

Posted on 5 years ago

Bhumi

MySQL coalesce() function

Updated 17 years ago

Bhumi

How to use JavaScript Promise API?

Updated 17 years ago

Bhumi

What are Lambdas and Closures in PHP?

Updated 17 years ago

Bhumi

An Introduction to Gulp JS

Updated 2 months ago

Bhumi

The Reader’s Poll – June 2015

Posted on 2 years ago

Bhumi

The Reader’s Poll – August 2014

Posted on 3 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 3 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 3 years ago

Bhumi

The Readers’ Poll – August 2013

Posted on 4 years ago

Bhumi