Change WordPress user roles and capabilities › Forums › How to or FAQ › Defining Posts View Access in php › Reply To: Defining Posts View Access in php
09/01/2021 at 13:48
#7249
Vladimir
Keymaster
Hi,
Yes, it’s possible. Just select suitable access model:
$restriction[‘access_model’] = 1; // Prohibit view
and
$restriction[‘access_model’] = 2; // Allow view
$restriction[‘data’][‘posts’] = array( 10, 20, 30 ); // posts/pages/custom post types ID list
Post ID array works for any post type: as WordPress built-in posts and page, as any custom post type.