회원관리 플러그인 페이지 제한 부모-자식 페이지 적용 관련

1. 정확한 제품 또는 플러그인 이름

코스모스팜 회원관리 최신버전

 

2. 상세 내용

안녕하세요. 아래 코드를 자식테마 functions.php 파일에 넣어서 부모 페이지의 아이디만 입력하면 그 아래 자식 페이지까지 모두 비회원 접근제한이 되도록 만들었습니다.

그런데 회원관리 플러그인의 기능 중 하나인, 페이지 수정에서 '페이지 제한'이 있잖아요? 사용자 역할을 지정해서 해당 역할을 가진 회원만 접근 가능하도록 하는 것인데, 이 기능을 부모 페이지에 설정하면 그 아래 자식 페이지까지 모두 설정이 적용되도록 하고 싶습니다. 아래 코드를 응용하면 될 것 같은데, 코스모스팜 회원관리 플러그인 어느 파일 어느 라인을 어떻게 수정해야 할까요?

//부모 페이지와 자식페이지 모두 비회원 접근제한
add_action('template_redirect', 'redirect_to_specific_page');
function redirect_to_specific_page() {
  $parent_ids = array( 460, 2427, 3695, 10202);
  $child_pages = array();
  
  // loop through the parent pages
  foreach ($parent_ids as $parent_id) {
    // Get all child pages of the parent page
    $args = array(
      'post_type' => 'page',
      'post_parent' => $parent_id,
      'posts_per_page' => -1,
      'fields' => 'ids'
    );
    $child_pages = array_merge($child_pages, get_posts($args));
  }
  // Add the parent page IDs to the array of child pages
  $child_pages = array_merge($child_pages, $parent_ids);
  
  if ( is_page( $child_pages ) && !is_user_logged_in()) {
    $return_url = esc_url( home_url( '/login/' ) ); // Redirect to your custom login page in WordPress
    wp_redirect( $return_url );
    exit;
  }
}

 

 

 

워드프레스 에러 기술지원 서비스 전문가에게 맡기세요
좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
워드프레스 에러 기술지원 서비스 전문가에게 맡기세요