What is the recommended way to create plugin administration forms?

I personally just add a menu link and in the function for it handle the form. With $_SERVER[‘REQUEST_URI’] as the action. Example below.

add_action("admin_menu", "menu" );
function menu(){
    add_menu_page('Test form', 'Test form', 'manage_options', 'show_form' );
}
function show_form(){
    if ( $_SERVER["REQUEST_METHOD"] == "POST" ){
            print "do stuff";
    } else {
         ?><form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"><input type="submit" /></form><?php
        }
}

Leave a Comment