role is found in array of allowed role, no redirection needed * */ $allowed_roles = array($role_admin, $role_fipf); if (array_intersect($allowed_roles, $current_user->roles)) return; PLGNTLS_class::debug_infos(); /* * get_queried_object_id() would work too * here get_the_author_meta works and is more explicit * $author_id = get_queried_object_id(); */ $author_id = get_the_author_meta( 'ID' ); $current_user_id = get_current_user_id(); if ($current_user_id != $author_id) { // Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes nocache_headers(); wp_redirect(home_url(), 301); exit; } PLGNTLS_class::debug_infos(); } add_action('template_redirect', 'restrict_author_page_CIPF', 10); ?>