Reputation: 544
I just noticed that admin-post.php
doesn't fired for me.
I have a simple form :
<form method="POST" action="<?php echo esc_url( admin_url('admin-post.php') ); ?>" >
<?php wp_nonce_field( 'customLoginConnect', 'customLoginConnectNonce' ); ?>
<input type="hidden" name="action" value="customLoginConnect" />
<input class="form-control" type="email" name="user_email" required>
<input class="form-control" type="password" name="user_pwd" required>
</form>
And this :
add_action( 'admin_post_nopriv_customLoginConnect', 'customLoginConnect' );
add_action( 'admin_post_customLoginConnect', 'customLoginConnect' );
When I submit this, I get blank page..
I have Wordpress 5.4.1 and I deactivate ALL my plugins and change theme.
I put WP_DEBUG
as true
and see no errors. Nothing !
I do something wrong ?
Upvotes: 1
Views: 2196
Reputation: 525
The following is added to functions.php file
add_action( 'admin_post_nopriv_customLoginConnect', 'customLoginConnect' );
add_action( 'admin_post_customLoginConnect', 'customLoginConnect' );
The function definition is also added to the functions.php file. Ex:
function customLoginConnect()
{
//Please add your code here
$url = $_POST['_wp_http_referer'];
wp_redirect($url);
}
The error is usually caused by a filter or an action not properly declared. Can you please check this. Now you say you get a white page. This is because we need to redirect back to our form. I've used a simple wp_redirect(). Hope this will resolve your problem.
Upvotes: 3