• Hello,

    I currently have a template file that redirects users to separate pages based on whether or not they’re logged in. It is shown below. This is so I can show different versions of the home page to registered and non registered users. I need to create (or modify) a template file to redirect based on user role.

    For example, susbscribers who visit redirectpage are redirected to page-a, and editors are redirected to page-b. Is this possible?

    Thank you!

    <?php
    ob_start();?>
    /*
    Template Name: redirecT Courses
    */
    ?>
    
    <?php get_header(); ?>
    
    <?php if (is_user_logged_in()) {
    wp_redirect('courses-3');
    
    } else {
    wp_redirect('courses');
    } ?>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
     ob_end_flush();>

The topic ‘Template – Redirect page based on user role’ is closed to new replies.