I created a custom page in the wordpress admin which has a simple file upload field and a submit button. I need to figure out how to submit the page to somewhere it can be processed but can't find anything on the web. Does anyone know what the 'action' needs to be on the form to get it to go to a function or another page where i can process the file?
All your form entries (leads) are stored in your WordPress database and are easily accessible from inside your WordPress dashboard.
use this code snippet:
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
}
Thanks Mr. Hunter. Couldn't credit you for the right answer.
Wrapped the form in a if(isset($_POST['submit'])) and then called my functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With