This is a sample hook that is run after a particular form on a Wordpress admin page is submitted, which I found in this StackOverflow answer:
public function foobar_save_admin_action()
{
// Do your stuff here
wp_redirect( $_SERVER['HTTP_REFERER'] );
exit();
}
Is the exit()
required after wp_redirect()
? What would happen if I didn't write it?
This answer says that you should write exit
or die
after performing the redirect but it doesn't explain why.