admin_post_{$action} won’t work in theme
-
I’m using
admin_post_{$action}
to handle the form. I just copy-paste the example from https://developer.www.ads-software.com/reference/hooks/admin_post_action/.I created
front-page.php
in the theme directory and just paste in:<form action="https://www.example.com/wp-admin/admin-post.php" method="post"> <input type="hidden" name="action" value="our_action_hook"> <input type="submit" value="Submit"> </form>
Then this in the functions.php :
add_action( 'admin_post_our_action_hook', 'am_our_action_hook_function' ); function am_our_action_hook_function() { // do something }
But I got an error in the console:
400 bad request
. If I make this as a plugin, it works. But if I do it in a theme, it doesn’t…
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘admin_post_{$action} won’t work in theme’ is closed to new replies.