Home › Forums › Front End PM PRO › Limit Admins to specific roles
Tagged: Administrators, search, User Role
- This topic has 6 replies, 2 voices, and was last updated 6 months ago by Shamim Hasan.
- 
		AuthorPosts
- 
		
			
				
April 12, 2025 at 11:16 am #45951Craig TuckerParticipantHello Shamim, I am setting up the plugin to run client to admin. I have several admins. They work with specific client roles. I would like to limit the access of the admin to the roles to which they are assigned. So, I would like the search and directories to associate the admin to their assigned role. I do not want them to have access to other roles. Is there a filter I can use to help make this happen? Craig April 12, 2025 at 11:37 am #45952Craig TuckerParticipantIt looks like fep_directory_arguments may do it? April 17, 2025 at 1:08 pm #45953Shamim HasanKeymasterDo you want such a way that an Editor role user only see other Editor role users? you can use fep_directory_argumentsandfep_filter_rest_users_argsApril 29, 2025 at 1:28 pm #45955Craig TuckerParticipantHello Shamim, I am finally getting to my project. I want Doctors to only see their patients in their mail box. I have a clinic with three doctors. I want all doctors on FEP. When patients register they are assigned a user role associated with their doctor. I can see how I can use fep_directory_arguments so that if the doctors only their patients in the directory. I also need for doctors to only see their patients when they look at the message board. Is there a filter I can use for how messages load into the first page of the message board? Or, will I need to edit the template files? If so, which are associated with the front page of the message board? Thank you, 
 CraigMay 2, 2025 at 12:18 am #45957Craig TuckerParticipantI am wondering about the filter: fep_message_query_args_ 
 What are the parameters of this? Can I create a custom query to filter what messages appear in the message box?Craig May 2, 2025 at 8:57 am #45958Craig TuckerParticipantI 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. 
 CraigMay 2, 2025 at 9:12 am #45960Shamim HasanKeymasterAs i understand you want only doctor’s self patients will be shown to that doctor. Eg. your doctors roles are A, B and C. And patients of doctor A’s are patients_of_A. So your filter will look like add_filter( 'fep_filter_rest_users_args', function( $args ){ if ( in_array( 'A', wp_get_current_user()->roles ) ) { $args['role'] = 'patients_of_A'; } return $args; });As i understand you do not need to filter messages. 
- 
		AuthorPosts
You need to purchase ‘Front End PM PRO’ to create topic in this support forum.
If you already purchased ‘Front End PM PRO’ please LOGIN.