Change WordPress user roles and capabilities › Forums › How to or FAQ › Access to all Posts of a specific Custom Post Type and limit other Pages by ID › Reply To: Access to all Posts of a specific Custom Post Type and limit other Pages by ID
31/03/2020 at 14:46
#6733
edering
Participant
Also, we already have this filter being used once for a different role/custom post type. How do we add it again, but make sure they run independently? See below.
// URE to allow Scholarship Role access to Scholarship plugin while restricting Pages for user
add_filter('ure_restrict_edit_post_type', 'exclude_posts_from_edit_restrictions', 10, 1);
function exclude_posts_from_edit_restrictions($post_type) {
$restrict_it = $post_type;
$user = wp_get_current_user();
if ( empty( $user) || !is_array( $user->roles ) ) {
return $restrict_it;
}
if ( in_array( 'scholarships', $user->roles ) ) { // Role ID
if ($post_type=='scholarship') { // CPT ID
$restrict_it = false;
}
}
return $restrict_it;
}
// end URE to allow Scholarship Role access