Ferodynamics Network

popular: profile privacy, mobile privacy

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

Post Image The Easy Peasy Way
26 comments
page 1065
Quick N Dirty Admin Login Screen
no comment
page 128
Wordpress Chat
one comment
page 1308
Html 5 Gallery
6 comments
page 1305
Html 5 Gallery
6 comments
page 1305
Silence Is Golden
3 comments
page 213
Questions About Habari For Wordpress Users
6 comments
page 424
Theming Habari Vs Wordpress
13 comments
page 440
My Experience Of Flexx
4 comments
page 1026
Plugin Update Fun With Photo Data 2
one comment
page 815
Post Image The Easy Peasy Way
26 comments
page 1065
Categories Vs Tags Either Neither Or Both
12 comments
page 7
Gaining Benefits From Plugins
8 comments
page 1167
Fun With Theme Widgets
24 comments
page 867
Beware Wp Cache
8 comments
page 1310
Six Million Ways To Die Choose One
14 comments
page 1128
Post Image The Easy Peasy Way
26 comments
page 1065
Post Image The Easy Peasy Way
26 comments
page 1065
Wordpress Chat
one comment
page 1308
Post Image The Easy Peasy Way
26 comments
page 1065
Wordpress Chat
one comment
page 1308
Beware Wp Cache
8 comments
page 1310
Wp Polls Reviewed
one comment
page 58
Fun With Photo Data
12 comments
page 330
Fun With Sidebar Tabs Styling
2 comments
page 336
Html 5 Gallery
6 comments
page 1305
Using Your Own Url Shortener
4 comments
page 1190
Html 5 Gallery
6 comments
page 1305
My Experience Of Flexx
4 comments
page 1026
Fun With Sidebar Tabs
193 comments
page 57
Html 5 Gallery
6 comments
page 1305
  updated 1 seconds ago
Thursday, 12pm
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….