Infinite loop with wp_redirect
-
Good Morning,
I created a custom work added to my functions.php:add_action('wp', 'personal_message_when_logged_in' ); function personal_message_when_logged_in() { if ( is_user_logged_in() ) { $user = wp_get_current_user(); $logincontrol = get_user_meta($user->ID, '_new_user', 'TRUE'); $acceptPrivacyControl = get_user_meta($user->ID, '_user_accept_privacy', 'TRUE'); //Se entrambi sono TRUE eseguo il redirect if ( $logincontrol and acceptPrivacyControl) { echo $redirect_url = get_site_url() . "/trattamento-dei-dati-personali/"; wp_redirect( home_url(), 301 ); exit; } } }
Tested the value of the two TAG _new_user and are _user_accept_privacy are both TRUE then performs the redirect.
The problem is on wp_redirect:
– If inserted simplewp_redirect ('https://www.example.com', 301); exit;
redirect is performed
– If I leave the code as the browser loads indefinitely.Why?
Thanks.
- The topic ‘Infinite loop with wp_redirect’ is closed to new replies.