I am trying to redirect users(subscribers) to a particular page based on the following conditions
1. (subscriber) user is logged on 2. specific page id is matched 3. wp user role = subscriber
which is the default role set when a user is registered on the platform
The Challenge i am having is conditions 1 and 2 works but not 3.
Here is my code:
function add_login_check()
{
if ( is_user_logged_in() && is_page(1865)) {
wp_redirect('http://destredirectedpage.php');
exit;
}
}
add_action('wp', 'add_login_check');
Interesting enough when i tested the above code using administrator role it works as expected but with subscriber role i get redirected automatically to the subscriber profile page upon logon.