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; /* * 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) { wp_redirect(home_url(), 301); exit; } } add_action('template_redirect', 'restrict_author_page_CIPF', 10); ?>