Reply To: Roles or Edit only in the same Location

Front Page Forums HRM Roles or Edit only in the same Location Reply To: Roles or Edit only in the same Location

#6905
JuacOHI
Participant

Sorry if i wasn’t clear.

I’m asking if is possible to only let people edit employees that are from the same location. (From ERP Settings -> Locations), which when you add a new employee is this data: (I deleted the part that it says php becaue can’t paste php code)
<li data-selected="{{ data.work.location }}">
erp_html_form_input( array(
'label' => __( 'Location', 'erp' ),
'name' => 'work[location]',
'value' => '{{ data.work.location }}',
'custom_attr' => array( 'data-id' => 'erp-company-new-location' ),
// 'class' => 'erp-hrm-select2-add-more erp-hr-location-drop-down',
'class' => 'erp-hrm-select2',
'type' => 'select',
'options' => erp_company_get_location_dropdown_raw()
) );

So, in resume if I have 3 locations (main location, second and third), and I have an employee that can manage HRM , and this person is from Main Location, only let him edit employees that are from Main Location and NOT from second and third.
After taking in consideration what i just said, if i go to single.php (where you can find all the code to show the employee), I think that I could add a condition in the button edit to ONLY show that button if i’m from the same Location, and if not, hide the button but i can still see the employee from other locations.

So I think that the code would be something like… get current user and ask his location, and then ask the location of the employee that i’m seeing, and if both match, let me edit that employee.
My best guess is that it should be in this line of code, which is when it shows the edit button in the Action Box.
<h3 class="hndle"><span>( 'Actions', 'erp' ); ?></span></h3>
<div class="inside">

if ( current_user_can( 'erp_edit_employee', $employee->id ) ) {

<span class="edit">id; ?>" data-single="true" href="#">_e( 'Edit', 'erp' ); ?></span>
}

Contact Us

Reach out to us for any inquiry

You must enter full name
You must enter email
You must enter message

We received your message

We will reach you with your email address soon. Thank you for the time!