• I’m new to creating admin custom plugins for WordPress. I need to create a page that allows the admins to upload an excel file that will then be read and inserted into the WordPress database.

    I created a new top level menu item which opens a page that offers the users a upload file input. I am curious how I can submit that form to a custom funtion that will upload the file and then read the contents and write it to the database. I think I can handle the upload,read, and insert but I have no idea what to use as the action in my form to fire off my custom code.

    Here is my functions.php I created to handle this so far.

    add_action( 'admin_menu', 'recipe_upload' );
    
    function recipe_upload() {
    	//add_options_page( 'Recipe Uploader', 'Upload Bulk Recipes', 'manage_options', 'bulk-reciper-loader', 'recipe_uploader_options' );
    	 add_menu_page( 'Recipe Uploader', 'Recipe Uploader', 'manage_options', 'bulk-reciper-loader', 'recipe_uploader_options');
    }
    
    function recipe_uploader_options() {
    	if ( !current_user_can( 'manage_options' ) )  {
    		wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
    	}
    echo '<div class="tool-box">
    <h3>MHealthy Bulk Recipe Uploader</h3>
    <p>Using the file select below, upload your completed spreadsheet of new recipes to import into the recipe database website.</p>
    </div>
    <div class="tool-box">
    <form action="????" name="uploader_form" method="post">
    <input type="file" name="recipe_sheet" accept="application/msexcel" />
    <br /><br />
    <input type="submit" name="submit" id="submit" value="Upload!" />
    </form>
    </div>
    			';
    }

The topic ‘Submitting to a function from a new admin menu’ is closed to new replies.