I am trying to redirect users based on the following...
- If Role = Customer & Page Is NOT ID 6 Then Redirect To Checkout
- If Not Logged in & Page Is Not ID 6 then redirect to login
User role = member and Page ID is 6 redirect to home page
//If Role = Customer & Page Is ID 6 Then Redirect To Checkout if ( user_can( $current_user, "customer" ) && ! is_page( 6 ) ) { wp_redirect(home_url().'/checkout'); exit; } elseif ( ! is_page ( 6 ) ) { //If Not Logged in & Page Is Not ID 6 then redirect to login auth_redirect(); } elseif ( user_can( $current_user, "member" ) && is_page( 6 ) ) { // User role = member and Page ID is 6 redirect to home page wp_redirect(home_url()); exit; } ?>
Which as far as I can see should work, but its not, it gives me a blank page. The script is being run from header.php and is the first thing in the PHP file.
The first rule - If Role = Customer & Page Is ID 6 Then Redirect To Checkout works correctly and they are redirected to the checkout page.
The second rule prevents anybody from logging in
The third rule works correctly
Am I doing something wrong?