submitting form to admin-panel.php returns 500 error

<form action="<?php echo esc_url( admin_url('admin-post.php') ); ?>" method="post">
        <input id="user_name" type="text" name="yourname" placeholder="Name">
        <input id="user_email" type="text" name="email" placeholder="Email">
        <button id="button" type="button" name="submit">Go</button>
        <input type="submit" value="submit" name="submit">
        <input type="hidden" name="action" value="login_form">


function prefix_send_email_to_admin() {
     * At this point, $_GET/$_POST variable are available
     * We can do our normal processing here

    // Sanitize the POST field
    // Generate email content
    // Send to appropriate email
        wp_redirect( "http://example-website/projects/webdev/wordpress_nepal/quiz/" );
add_action( 'admin_post_nopriv_login_form', 'prefix_send_email_to_admin` );
  • You've got an incorrect quote here: 'prefix_send_email_to_admin` That last one isn't a quote, it's a backtick. Make sure it's a quote. – Jacob Peattie Nov 13 '18 at 10:09
  • @JacobPeattie Thanks, that was stupid mistake. But do you know how can I use wp_redirect to redirect person to a new page? Now I just copied URL from the browser of the page I want to be redirected to, but it doesn't work that way for some reason? – Limpuls Nov 13 '18 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.