Submitting a form on a custom admin page in wordpress

前端 未结 4 2257
没有蜡笔的小新
没有蜡笔的小新 2021-02-19 21:21

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 proce

4条回答
  •  长发绾君心
    2021-02-19 22:05

    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()
    {
    ?>
        

提交回复
热议问题