Here is a very basic example of how to use it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | add_action( 'admin_action_wpse10500', 'wpse10500_admin_action' ); function wpse10500_admin_action() { // Do your stuff here wp_redirect( $_SERVER['HTTP_REFERER'] ); exit(); } add_action( 'admin_menu', 'wpse10500_admin_menu' ); function wpse10500_admin_menu() { add_management_page( 'WPSE 10500 Test page', 'WPSE 10500 Test page', 'administrator', 'wpse10500', 'wpse10500_do_page' ); } function wpse10500_do_page() { ?> <form method="POST" action="<?php echo admin_url( 'admin.php' ); ?>"> <input type="hidden" name="action" value="wpse10500" /> <input type="submit" value="Do it!" /> </form> <?php } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.