Page Redirect Issue
-
I currently have the code below added to my functions.php in order to redirect the users when they visit my website. The user is only redirected if the value of ‘update_racer_record’ is set to ‘YES’.
However, I am getting a ‘too many redirects’ issue because WordPress keeps redirecting the user even after he has reached the final page. In order to stop this I added the ‘is_page’ condition, but that doesn’t seem to be working. I’m still getting the ‘too many redirects’ error.
What am I missing?
add_action( 'init', 'my_redirect' ); function my_redirect(){ global $wpdb; // if user is logged in if( is_user_logged_in() ) { // set vars $racer_id = find_racer_id(); $update_racer_record = 'NO'; // check to see if the user record has been updated in the last 6 months $update_racer_record = $wpdb->get_var(" select 'YES' from flx_racers where racer_id = " . $racer_id . " and ifnull(update_date, date_sub(now(), interval 7 month)) < date_sub(now(), interval 6 month); "); // if user record has not been updated in the last 6 months, redirect if ( $update_racer_record == 'YES' ) { // if we are not currently already in the personal info page, then redirect to it if ( !is_page( 'flx-racer-personal-info' ) ) { wp_redirect( site_url().'/flx-racer-personal-info/' ); exit; } } } }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Page Redirect Issue’ is closed to new replies.