Developer Documentation

Add an Employee Status

WP ERP has five employee statuses: Active, Inactive, Terminated, Deceased, and Resigned. You can add a status, for example Retired, with the erp_hr_employee_statuses filter.

Note: In WP ERP 2.0.0, the new HR screens do not show a status that you add with this filter. Read Limits in WP ERP 2.0 before you use it.

Before you start

  • You must be able to add PHP code to your site, for example in a small plugin or a must-use plugin.
  • Do not change the files of WP ERP. An update replaces them.

Where the statuses come from

The function erp_hr_get_employee_statuses() returns the list of statuses. It is in erp/modules/hrm/includes/functions-employee.php, at about line 538 in WP ERP 2.0.0.

function erp_hr_get_employee_statuses() {
    $statuses = [
        'active'     => __( 'Active', 'erp' ),
        'inactive'   => __( 'Inactive', 'erp' ),
        'terminated' => __( 'Terminated', 'erp' ),
        'deceased'   => __( 'Deceased', 'erp' ),
        'resigned'   => __( 'Resigned', 'erp' ),
    ];

    return apply_filters( 'erp_hr_employee_statuses', $statuses );
}

The key (for example active) is the value that WP ERP saves in the database. The label (for example Active) is the text that users see.

Add the status

  1. Make a file in wp-content/mu-plugins/, for example erp-retired-status.php. If the folder does not exist, make it.
  2. Add this code to the file:
<?php
/**
 * Plugin Name: WP ERP Retired status
 */
add_filter( 'erp_hr_employee_statuses', function ( $statuses ) {
    $statuses['retired'] = __( 'Retired', 'erp' );

    return $statuses;
} );
  1. Save the file. WordPress loads must-use plugins automatically.

Use a short key with lowercase letters and no spaces. Do not change or remove the five default keys. WP ERP uses them in its own code.

Limits in WP ERP 2.0

The new HR screens in WP ERP 2.0 use a fixed list of the five default statuses. We tested the Retired example on WP ERP 2.0.0:

PlaceShows the new status
The status tabs on People → All EmployeesNo
The Employee Status field on the Add and Edit employee formsNo
The status check of the HR API (/wp-json/erp/v2/employees)Yes. The API accepts retired as a status.

So a developer can save the new status through the API, but HR managers cannot select it on the new screens, and the employee list has no tab for it.

An employee with a custom status does not count as a user for the WP ERP Pro license, because only Active employees count. See How WP ERP Pro Counts Users.

What changed in 2.0

  • The default list has five statuses, with Inactive. The old doc showed only four.
  • The function is in functions-employee.php. The old doc gave the file name function-employee.php and line 540.
  • The new HR screens do not read this filter. In WP ERP 1.x, the employee forms showed the added status.

Was this article helpful to you?

How can we help?