/*
Theme Name: Lightning Child
Theme URI: https://lightning.vektor-inc.co.jp/en/
Template: lightning
Author: Vektor,Inc.
Author URI: https://www.vektor-inc.co.jp
Description: Lightning is a very simple &amp; easy to customize theme which is based on the Bootstrap. It is also very friendly with custom post types and custom taxonomies. When you add a new one, the breadcrumbs will be adjusted and posts will look beautifully without editing or adding a template files.
Tags: blog,one-column,custom-background,custom-colors,custom-logo,custom-menu,editor-style,featured-images,footer-widgets,full-width-template,sticky-post,theme-options,threaded-comments,translation-ready,block-styles,wide-blocks
Version: 15.30.1.1756275772
Updated: 2025-08-27 15:22:52

*/
function restrict_pages_for_subscribers() {
    if ( is_page(array(
        'video-list',
        'lesson-01',
        'lesson-02',
        'lesson-03',
        'lesson-04',
        'lesson-05',
        'lesson-06',
        'lesson-07'
    )) ) {
        if ( !is_user_logged_in() ) {
            auth_redirect(); // 未ログイン → ログイン画面
        } else {
            $user = wp_get_current_user();
            if ( !in_array('subscriber', (array) $user->roles) ) {
                wp_redirect(home_url()); // 購読者以外 → トップ
                exit;
            }
        }
    }
}
add_action('template_redirect', 'restrict_pages_for_subscribers');

