redirection towards site_url doesn't work whereas it's ok with admin_url !
-
Hello everyone, it’s quite surprising (at my level)!
By looading a plugin I develop, I instantiate an object whose constructor initializes a hook as follows:
function __construct () {
add_action ( ‘template_redirect’, array ($this, ‘my_redirect’));
add_action ( ‘current_screen’, array ($this, ‘my_redirect’));
}The method ‘my_redirect’ overwrites ‘wp_redirect’ as follows:
` my_redirect function () {
…. Some preparation work..
wp_redirect (admin_url ( ‘profile.php’));
exit; }`This works fine: that is, just after he logs in, the user is redirected to its profile page, in the administration part.
THEN I tell myself that if I want to redirect to a page in the ‘front-end’, I have to write:
` my_redirect function () {
…
wp_redirect (site_url ( ‘mypage.php’));
exit;}`Well, no ! the browser returns “page is not redirected correctly!”
(I precise that the url is valid, of course).Would you know why ?? Any help will be greatly appreciated …. thank you in advance
Pierre
- The topic ‘redirection towards site_url doesn't work whereas it's ok with admin_url !’ is closed to new replies.