I have tried using fep_message_query_args
//Limit Clinician View in Mailbox to Only their Clients
add_filter( ‘fep_message_query_args’, function( $args, $user_id ) {
$current_user = wp_get_current_user();
$current_user_id = $current_user>id;
if(array_intersect($current_user->roles, array(‘administrator’, ‘ Amelia Employee’,’Amelia Manager’))) {
$user_role= ‘client’ . $current_user_id;
$args1 = array(
‘role’ => $user_role,
‘orderby’ => ‘id’,
‘order’ => ‘ASC’
);
$clients = get_users($args1);
foreach ($clients as $user) {
$args[‘participant_query’][] = array(
‘mgs_participant’ => $user->id,
‘mgs_deleted’ => false,
);
return $args;
}
}
}, 10, 2 );
This did not work. The foreach loop is not effective. It appears to need one user id at a time. If, for example, I just feed mgs_participant a single ID all is well for that individual. But I need all individuals who may belong to that clinician to be represented in the message box. If you have any other options I can try to make this happen please let me know.
Craig