Hiding Employee list to the Employees in WPERP

You may often think, How to hide the Employee list in WPERP. In WPERP, when the Employee login, they can see the list of all Employees. Though they could not see any information that can cause other employee privacy. Employees can see the other Employee list and they can see their profile which contains only Email and Contact number.

An employee can see other employees list

This is actually a default feature of WPERP. It lets the Employees see other Employee profile with just the contact information with the sense that, one Employee may require to contact with another, in their purposes. So, having contact information visible is good to have good communication withing the Employee.

However, as I provide support for WPERP, I got queries sometimes that they do not want to let the other users see the Employee list. That seems a privacy issue to them and they are concerned with it.

I do help people with this by guiding them on how they can hide the Employee list for the other Employee. As I do get the same query often, I think it’s good to write about it that people can find it easily.

How to hide the Employee list in WPERP?

Well, it’s a simple trick, which you need to change from codes. Just open the file: /erp/modules/hrm/includes/admin/class-menu.php in the line number 39, Replace the erp_list_employee by erp_hr_manager

So, the code will be like:

erp_add_menu( 'hr', array(
            'title'       => __( 'Employees', 'erp' ),
            'capability'  => 'erp_hr_manager',
            'slug'        => 'employee',
            'callback'    => [ $this, 'employee_page' ],
            'position'    => 5,
        ) );

You can replace the codes from the line number 37 to 43. It will be something like this:

READ  Adding custom fields in default WordPress registration form

After changing accordingly, you’ll see the Employee menu is hidden for the Employee and that could be seen by the HR Manager Only.

The Employee list is hidden to the other Employees

I hope this helps. Feel free to ask in the comment if you get any queries. I love questions 🙂

You may also like: How to create a documentation site from the scratch

Leave a Reply