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:

See also  Validate Duplicate Display Name with WP User Frontend

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

Comment List

  • Juanjo 05 / 05 / 2021

    Thank you for the tips, Hasan!
    We want to do this on the HR Frontend too. Is this possible in the same way?
    Is this tweak “update-proof”?
    Thanks in advance!

    Reply
    • Mehedi Hasan 06 / 05 / 2021

      Hello Juanjo,

      Unfortunately no, it’s not update-proof. This means, you need to implement this every time after an update. Also, this is for the backend only.

      Thanks

      Reply
  • Jhon 25 / 08 / 2021

    Hi, I wonder if you edit this file is it not overwritten when you upgrade the plugin?

    Reply
    • Mehedi Hasan 25 / 08 / 2021

      Hello Jhon,

      Yes, this will be replaced after an update. You need to insert the same again after an update.

      Thanks

      Reply

Leave a Reply