Problem with is_page & wp_redirect

You need to separate the redirect function from the setcookie function For setcookie function use add_action(‘wp’, ‘your_cookies_function_name’,10,1) Note that it’s recommended to use wp and not init because is_page will not work with init And for the redirect function: function your_redirect_function_name() { if(is_page(‘uae’) && $_COOKIE_[‘region’] !== “UAE”){ wp_redirect(‘http://domain.com/uae/’); exit(); } } add_action( ‘template_redirect’, ‘your_redirect_function_name’,9 ); … Read more

wp_redirect not working from shortcode function

Why does it need to be a Shortcode? Looks like a XY Problem. You’re already inserting the shortcode manually in the edit screen. Use a Custom Field instead and hook earlier where you can actually do the redirect. add_action( ‘template_redirect’, function(){ global $post; $redirect = get_post_meta( $post->ID, ‘redirect’, true ); if( $redirect ) { wp_redirect( … Read more

Redirecting Subscriber Users to the home page after updating their profile

Hope this links will help you, link OR This is the function that you need: add_action( ‘profile_update’, ‘custom_profile_redirect’, 12 ); function custom_profile_redirect() { wp_redirect( trailingslashit( home_url() ) ); exit; } You can also set it for a specific User Role: add_action( ‘profile_update’, ‘custom_profile_redirect’, 12 ); function custom_profile_redirect() { if ( current_user_can( ‘subscriber’ ) ) { … Read more

how to block direct access to multiple thank you pages?

I have solved the issue by myself. I am posting the solution here in case if someone gets the same problem. function wpse15677455_redirect() { $ref = wp_get_referer(); if (is_page(1911) && $ref !== “https://www.example.com/contact”){ wp_redirect( get_home_url() ); } else if(is_page(1269) && $ref !== “https://www.example.com/contact-form-2”){ wp_redirect( get_home_url() ); } else if(is_page(1825) && $ref !== “https://www.example.com/contact-form-3”){ wp_redirect( get_home_url() … Read more

Why “exit” is needed after wp_redirect?

When you call wp_redirect it sends redirect HTTP headers, and that’s all the browser needs to redirect, there is no reason to continue executing code. So you must exit. wp_redirect will not do it for you, and PHP won’t do it for you if you send the http header to redirect. If you do not … Read more

Redirect to Referring URL after Login

Your code is completely flawed – not to mention you can’t redirect to the HTTP referer after login… because the referer is now the login page. Instead, use the login_redirect filter: add_filter( ‘login_redirect’, function ( $redirect_to, $requested_redirect_to ) { if ( ! $requested_redirect_to ) { $redirect_to = wp_get_referer(); } return $redirect_to; }, 10, 2 ); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)