admin管理员组文章数量:1023187
template:
<form action="<?php echo esc_url( admin_url('admin-post.php')); ?>" method="post">
<input type="text" name="boo" id="boo" required>
<input type="hidden" name="action" value="foo">
</form>
I have add the hook in theme functions.php and moo
is registered:
add_action( 'admin_post_foo', 'moo' );
add_action( 'admin_post_nopriv_foo', 'moo' );
function moo() {
wp_safe_redirect(
esc_url(
site_url( 'http://127.0.0.1:8000/?page_id=5' )
)
);
}
and still after post it hangs on admin_post.php
I don't have debug and I'm clueless of whether the hook is invoked so any idea of how to determine that as well?
template:
<form action="<?php echo esc_url( admin_url('admin-post.php')); ?>" method="post">
<input type="text" name="boo" id="boo" required>
<input type="hidden" name="action" value="foo">
</form>
I have add the hook in theme functions.php and moo
is registered:
add_action( 'admin_post_foo', 'moo' );
add_action( 'admin_post_nopriv_foo', 'moo' );
function moo() {
wp_safe_redirect(
esc_url(
site_url( 'http://127.0.0.1:8000/?page_id=5' )
)
);
}
and still after post it hangs on admin_post.php
I don't have debug and I'm clueless of whether the hook is invoked so any idea of how to determine that as well?
Share Improve this question asked Apr 25, 2019 at 12:27 Bat ManBat Man 1031 bronze badge1 Answer
Reset to default 0Let's say your site's address is example
. When you want to redirect to example/page/subpage
you should use site_url('/page/subpage')
.
I assume the WordPress address is http://127.0.0.1:8000
. You have in your code
site_url( 'http://127.0.0.1:8000/?page_id=5' )
and it will be converted to this address: http://127.0.0.1:8000http://127.0.0.1:8000/?page_id=5
.
Try using this redirection:
wp_safe_redirect( site_url( '/?page_id=5' ) );
Second issue, if you'll take a look at code reference, you will find there:
wp_safe_redirect() does not exit automatically and should almost always be followed by exit.
template:
<form action="<?php echo esc_url( admin_url('admin-post.php')); ?>" method="post">
<input type="text" name="boo" id="boo" required>
<input type="hidden" name="action" value="foo">
</form>
I have add the hook in theme functions.php and moo
is registered:
add_action( 'admin_post_foo', 'moo' );
add_action( 'admin_post_nopriv_foo', 'moo' );
function moo() {
wp_safe_redirect(
esc_url(
site_url( 'http://127.0.0.1:8000/?page_id=5' )
)
);
}
and still after post it hangs on admin_post.php
I don't have debug and I'm clueless of whether the hook is invoked so any idea of how to determine that as well?
template:
<form action="<?php echo esc_url( admin_url('admin-post.php')); ?>" method="post">
<input type="text" name="boo" id="boo" required>
<input type="hidden" name="action" value="foo">
</form>
I have add the hook in theme functions.php and moo
is registered:
add_action( 'admin_post_foo', 'moo' );
add_action( 'admin_post_nopriv_foo', 'moo' );
function moo() {
wp_safe_redirect(
esc_url(
site_url( 'http://127.0.0.1:8000/?page_id=5' )
)
);
}
and still after post it hangs on admin_post.php
I don't have debug and I'm clueless of whether the hook is invoked so any idea of how to determine that as well?
Share Improve this question asked Apr 25, 2019 at 12:27 Bat ManBat Man 1031 bronze badge1 Answer
Reset to default 0Let's say your site's address is example
. When you want to redirect to example/page/subpage
you should use site_url('/page/subpage')
.
I assume the WordPress address is http://127.0.0.1:8000
. You have in your code
site_url( 'http://127.0.0.1:8000/?page_id=5' )
and it will be converted to this address: http://127.0.0.1:8000http://127.0.0.1:8000/?page_id=5
.
Try using this redirection:
wp_safe_redirect( site_url( '/?page_id=5' ) );
Second issue, if you'll take a look at code reference, you will find there:
wp_safe_redirect() does not exit automatically and should almost always be followed by exit.
本文标签: functionsPostback redirect through addaction is not triggered
版权声明:本文标题:functions - Postback redirect through add_action is not triggered 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745553631a2155747.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论