You can add 2 approaches
Suppose current user id is 2 (you can get that using get_current_user_id()
) and connected users of this user in 2,3 and 4 (get that from your member plugin or using query)
Approach 1. You show only connected users in auto suggestion and in directory.
add_filter( 'fep_filter_rest_users_args', function( $args, $for, $q, $x ) {
$args['meta_query'] = [
'include' => [2,3,4], //Get ids from member plugin
];
return $args;
}, 10, 4 );
Approach 2. restrict user from sending message to only connected users
add_filter( 'fep_current_user_can', function( $can, $cap, $id ){
if ( 'send_new_message_to' != $cap || ! $can ) {
return $can;
}
//Get ids from member plugin
if( in_array($id, [2,3,4] ) ){
return true;
}
return false;
}, 10, 3);