Limit Admins to specific roles


Home Forums Front End PM PRO Limit Admins to specific roles

This topic is: Not Resolved
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #45951
    Craig Tucker
    Participant

    Hello 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

    #45952
    Craig Tucker
    Participant

    It looks like fep_directory_arguments may do it?

    #45953
    Shamim Hasan
    Keymaster

    Do you want such a way that an Editor role user only see other Editor role users? you can use fep_directory_arguments and fep_filter_rest_users_args

    #45955
    Craig Tucker
    Participant

    Hello 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,
    Craig

    #45957
    Craig Tucker
    Participant

    I 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

    #45958
    Craig Tucker
    Participant

    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

    #45960
    Shamim Hasan
    Keymaster

    As 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.

Viewing 7 posts - 1 through 7 (of 7 total)

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.