There is an HTML form input. Here's the code:
<?php if(isset($_POST['login'])) {
wp_redirect("/");
}
<form accept-charset="UTF-8" method="post" >
...
<center><input name="login" type="submit" value="вход" />
</form>
But redirect doesn't work. Install debug plugin redirects to wp, that's what it showed.
http://i.stack.imgur.com/Im4eE.png
PS:
<?php wp_redirect( 'http://www.example.com', 301 ); exit; ?>
It does not work either.
A URL may not be redirecting for many reasons: Browser cache – Your browser has cached a previous request. Clear your browser cache to get the latest. Server cache – Your site is being cached with some caching software, and this needs to be updated to include your redirect.
One of the main causes is because you have added the rewrite rules on both the cPanel “Redirects” tool and from your WordPress plugin. You can determine this by viewing your . htaccess file and looking if the rewrite rules you created from WordPress appear before the ones you entered using cPanel.
Description. Checks whether the $location is using an allowed host, if it has an absolute path. A plugin can therefore set or remove allowed host(s) to or from the list. If the host is not allowed, then the redirect defaults to wp-admin on the siteurl instead.
Just use this as per below:
ob_clean();
$url = get_home_url() . '/login';
wp_redirect($url);
exit();
Or you could use Javascript as well for redirection purpose.
<script>window.location='http://www.google.com'</script>
Use the follwing code:-
function app_output_buffer() {
ob_start();
} // soi_output_buffer
add_action('init', 'app_output_buffer');
Or add ob_start() as first line of your own function which hook into 'init'
Don't forget to add
exit();
immediately after your call to
wp_redirect($url);
link:
https://tommcfarlin.com/wp_redirect-headers-already-sent/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With