do_action( "admin_post_{$action}" )
Fires on an authenticated admin post request for the given action.
Description Description
The dynamic portion of the hook name, $action
, refers to the given request action.
Source Source
File: wp-admin/admin-post.php
Changelog Changelog
Version | Description |
---|---|
2.6.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
This hook allows us to create our own handler for GET or POST request. for example we want to call a function when form is submitted, we can do this with the following code.
<form action="http://www.example.com/wp-admin/admin-post.php" method="post">
<input type="hidden" name="action" value="our_action_hook">
<input type="submit" value="Submit">
</form>
This will submit form on the following url
http://www.example.com/wp-admin/admin-post.php?action=our_action_hook
in our function.php we can call the hook as “admin_post_” followed by {$action}
Expand full source codeCollapse full source code