#4814
Vladimir
Keymaster

Hi Arie,

Multiple functions on the same filter returns different results for the same custom post type as filter function does not take a result of a previously called code.

I recommend to use a single function for this filter with a logic for all you cases. Try this variant:


function exclude_posts_from_edit_restrictions($post_type) {
    $restrict_it = true;
    $current_user = wp_get_current_user();
    if (in_array($post_type, array('event', 'ctc_event'))) {
        if (in_array('hetbakenbeheren', $current_user->roles) && in_array('kerkdienstplanning', $current_user->roles)) {
            $restrict_it = false;
        }
    } elseif ($post_type=='ctc_sermon') {
        if (in_array('dominee', $current_user->roles)) {
            $restrict_it = false;
        }
    }
        
    return $restrict_it;
}

It does not restrict ‘event’ and ‘ctc_event’ CPT for a user who has both ‘hetbakenbeheren’ and ‘kerkdienstplanning’ roles at the same time.
It does not restrict ‘ctc_sermon’ CPT if user has ‘dominee’ role.