I have a function that checks some user meta and then redirects based off that. I'm pretty sure this was working before I updated everything on my site.
For some reason, now when someone logs in it is always redirecting to /updated-terms-and-conditions/
. I have checked the user meta after this happens and its set correctly, so I would expect it to redirect to /
.
Any ideas?
function redirect_login_to_tos($redirect) {
$user_id = get_current_user_id();
$checkout_tos2 = get_user_meta($user_id, 'checkout_tos2', true);
$checkout_tos3 = get_user_meta($user_id, 'checkout_tos3', true);
if($checkout_tos2 != 'agreed' || $checkout_tos3 != 'agreed'){
$redirect = '/updated-terms-and-conditions/';
}else{
$redirect = '/';
}
return $redirect;
}
add_filter('woocommerce_login_redirect', 'redirect_login_to_tos');