WordPress API

As of version 4.8.4, ShiftController provides a number of WordPress filters to query and update its shifts database.

Get Shifts

shiftcontroller4/api/shifts/get (array $params) : array | WP_Error

Parameters

calendar_id (Calendar Id)
employee_id (Employee Id)
from (From Date, YYYYMMDD / From Date Time, YYYYMMDDHHMM)
to (To Date, YYYYMMDD / To Date Time, YYYYMMDDHHMM)
status_id (publish, draft)

Examples

$res = apply_filters( 'shiftcontroller4/api/shifts/get', array() );
if( is_wp_error($res) ) exit( $res->get_error_message() );
$shifts = $res;
$params = array();
$params['calendar_id'] = 11;
$params['from'] = 20210224;
$res = apply_filters( 'shiftcontroller4/api/shifts/get', $params );
if( is_wp_error($res) ) exit( $res->get_error_message() );
$shifts = $res;
$params = array();
$params['calendar_id'] = 11;
$params['from'] = '202102240900';
$params['to'] = '202102241430';
$params['status_id'] = 'draft';
$res = apply_filters( 'shiftcontroller4/api/shifts/get', $params );
if( is_wp_error($res) ) exit( $res->get_error_message() );
$shifts = $res;

Get Shift

shiftcontroller4/api/shifts/getbyid ( $id ) : array | WP_Error

Examples

$res = apply_filters( 'shiftcontroller4/api/shifts/getbyid', 123 );
if( is_wp_error($res) ) exit( $res->get_error_message() );
$shift = $res;

Delete Shift

shiftcontroller4/api/shifts/deletebyid ( $id ) : null | WP_Error

Examples

$res = apply_filters( 'shiftcontroller4/api/shifts/deletebyid', 123 );
if( is_wp_error($res) ) exit( $res->get_error_message() );

Create Shift

shiftcontroller4/api/shifts/create ( array $values ) : int | WP_Error

Parameters

calendar_id (Calendar Id)
employee_id (Employee Id)
start (Start Date Time, YYYYMMDDHHMM)
end (End Date Time, YYYYMMDDHHMM)
status_id (publish, draft)
conflict (Set to 1 to allow creation of shifts with conflicts) optional

If you have custom fields in this calendar, then you can add them too as miscXXX where XXX is the field id (see Administration > Calendars > Custom Fields):

misc11
misc12

Returns the new shift id on success.

Examples

$values = array();
$values['calendar_id'] = 11;
$values['employee_id'] = 22;
$values['start'] = '202102240800';
$values['end'] = '202102241430';
$values['status_id'] = 'publish';
// if you have custom fields
$values['misc11'] = 'orange';
$values['misc12'] = 321;
$res = apply_filters( 'shiftcontroller4/api/shifts/create', $values );
if( is_wp_error($res) ) exit( $res->get_error_message() );
$newId = $res;

Update Shift

shiftcontroller4/api/shifts/updatebyid ( int $id, array $values ) : null | WP_Error

Parameters

calendar_id (Calendar Id) optional
employee_id (Employee Id) optional
start (Start Date Time, YYYYMMDDHHMM) optional
end (End Date Time, YYYYMMDDHHMM) optional
status_id (publish, draft) optional
conflict (Set to 1 to allow creation of shifts with conflicts) optional

If you have custom fields in this calendar, then you can add them too as miscXXX where XXX is the field id (see Administration > Calendars > Custom Fields):

misc11
misc12

Examples

$values = array();
$values['start'] = '202102240900';
$values['end'] = '202102241530';
$res = apply_filters( 'shiftcontroller4/api/shifts/updatebyid', 123, $values );
if( is_wp_error($res) ) exit( $res->get_error_message() );
$values = array();
$values['employee_id'] = 23;
// if you have custom fields
$values['misc11'] = 'green';
$res = apply_filters( 'shiftcontroller4/api/shifts/updatebyid', 123, $values );
if( is_wp_error($res) ) exit( $res->get_error_message() );
$values = array();
$values['status_id'] = 'publish';
$res = apply_filters( 'shiftcontroller4/api/shifts/updatebyid', 123, $values );
if( is_wp_error($res) ) exit( $res->get_error_message() );

Order Now

Get the Pro version for a lot more nice features

Buy Now

Contact Us

Please contact us should you have any questions.