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

How to setcookie if is_page(‘page’) ? should I use add_action(‘init’) or there is another action?

template_redirect and wp (as the OP noted in comments) are good hooks to do this. But there’s a problem of logic in the sample code. I think it should be like: add_action( ‘template_redirect’, ‘cookie_redirect_wpse_113662’ ); function cookie_redirect_wpse_113662() { # No cookie set, let’s do it if( !isset( $_COOKIE[‘site_language’] ) ) set_cookie_wpse_113662( ‘ar’ ); # One … Read more

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