admin管理员组

文章数量:1425109

I have this inside the <form></form>:

<input type="hidden" name="action" value="submit_images" data-parsley-excluded />

I have this as my hook just to test:

function maybe_add($entry, $form) {
        wp_redirect( '/', 301 );
        exit();
}
add_action( 'admin_post_submit_images', maybe_add_', 10, 2 );

I never get redirected to google though no matter what I've tried. Any ideas?

I have this inside the <form></form>:

<input type="hidden" name="action" value="submit_images" data-parsley-excluded />

I have this as my hook just to test:

function maybe_add($entry, $form) {
        wp_redirect( 'https://www.google/', 301 );
        exit();
}
add_action( 'admin_post_submit_images', maybe_add_', 10, 2 );

I never get redirected to google though no matter what I've tried. Any ideas?

Share Improve this question edited Jun 6, 2019 at 20:56 nmr 4,5672 gold badges17 silver badges25 bronze badges asked Jun 6, 2019 at 20:50 D.G.D.G. 1 2
  • you have an underscore after "maybe_add" in your add_action – rudtek Commented Jun 6, 2019 at 23:26
  • does this action hook actually exist? where did you get your code from? what are you trying to achieve? – Michael Commented Jun 7, 2019 at 21:29
Add a comment  | 

1 Answer 1

Reset to default 1

You're missing a ' in your code and your function name is different.

function my_maybe_add_redirect( $entry, $form ) {
    wp_redirect( 'https://www.google/', 301 );
    exit();
}
add_action( 'admin_post_submit_images', 'my_maybe_add_redirect', 10, 2 );

本文标签: actionsadminpost hook not working