August 30, 2008
I spent ages trying to find out how to do this. I knew it existed because I read about it but had no idea what to look for to find it. So this is a quick reminder write up.
If you write a plugin that creates an admin page, from WordPress 2.6 (I think) there is a new way to deal with the information the user posts from the form.
In the old days the form handling code would go at the top of the admin page function, or it could be hooked into other actions like the template selector. Now WordPress will create a custom hook.
In the admin page add a hidden form field called ‘action’ with a value of {pluginname}_{action}-{object}; so if you are updating a comment you might use ‘myplugin_comment-update’. You also need to change your form so it posts to admin-post.php.
Admin post will load all the WordPress functions and things, then create a custom hook called: ‘admin_post_’ + your action name. So you can create a new function for handling your form data and trigger it (using the same example) with add_action( ‘admin_post_myplugin_comment-update ‘myfunction’);
It is explained further on this page: http://codex.wordpress.org/Handling_POST_and_AJAX_Requests
Html 5 Gallery
6 comments
page 1305
Fun With Sidebar Tabs Styling
2 comments
page 336
Post Image The Easy Peasy Way
26 comments
page 1065
How To Add Sidebars To A Theme
10 comments
page 1053
Html 5 Gallery
6 comments
page 1305
Wordpress Vs Graffiti
8 comments
page 95
Poll Daddy Reviewed
2 comments
page 42
Html 5 Gallery
6 comments
page 1305
Html 5 Gallery
6 comments
page 1305
Post Image The Easy Peasy Way
26 comments
page 1065
Quick N Dirty Post Exclusion
11 comments
page 124
Using Your Own Url Shortener
4 comments
page 1190
My Experience Of Flexx
4 comments
page 1026
Html 5 Gallery
6 comments
page 1305
Wordpress Chat
3 comments
page 1308
Quick N Dirty Post Exclusion
11 comments
page 124
Post Image The Easy Peasy Way
26 comments
page 1065
Post Image The Easy Peasy Way
26 comments
page 1065
Auto Cycle Fun With Sidebar Tabs
one comment
page 1129
Post Image The Easy Peasy Way
26 comments
page 1065
Html 5 Gallery
6 comments
page 1305
Html 5 Gallery
6 comments
page 1305
Html 5 Gallery
6 comments
page 1305
Wordpress Chat
3 comments
page 1308
Using Your Own Url Shortener
4 comments
page 1190
Custom Hooks For Admin Pages
one comment
page 430
Custom Hooks For Admin Pages
one comment
page 430
Wordpress Chat
3 comments
page 1308
Html 5 Gallery
6 comments
page 1305
Html 5 Gallery
6 comments
page 1305
How To Add Sidebars To A Theme
10 comments
page 1053
Post Image The Easy Peasy Way
26 comments
page 1065
1 query every 1271 seconds, updated 1 seconds ago.
(__)
`
Leonaut.com
Custom Hooks for Admin Pages…
I spent ages trying to find out how to do this. I knew it existed because I read about it but had no idea what to look for to find it. So this is a quick reminder write up….