I have created a page template that will be used to show a custom wordpress login form.
<?php /* * Template Name: Login */ get_header(); if( !is_user_logged_in() ){ ?> html code <?php } else { $user = wp_get_current_user(); if( current_user_can('edit_users') && in_array('customrole', $user->roles) ){ wp_redirect( site_url('/role-page') ); exit; } if( current_user_can('edit_users') && in_array('customrole1', $user->roles) ){ wp_redirect( site_url('/role-page1') ); exit; } } get_footer(); ?> I've noticed that if an user is logged in, the page will be loaded and is blank, the users will be not redirected to the desired location. How I can fix this problem and let the logged users be redirected based on their role?