uo_ceu_credit_report_api_data
Filters the API data used for the CEU credit report before it's processed.
add_filter( 'uo_ceu_credit_report_api_data', $callback, 10, 2 );
Description
This filter hook allows developers to modify the API data used for the Course Report. It's applied just before the data is returned to the frontend for display. Developers can hook into this to alter, add, or remove any part of the `$api_setup` array, giving them full control over the report's data presentation. The `$this` parameter provides access to the current Course Report object.
Usage
add_filter( 'uo_ceu_credit_report_api_data', 'your_function_name', 10, 2 );
Parameters
-
$api_setup(mixed) - This parameter contains the data that will be used to set up the API response for the course credit report.
-
$this(mixed) - This parameter holds the data structure that will be sent to the API for the course credit report.
Return Value
The filtered value.
Examples
/**
* Example of modifying the CEU credit report API data.
*
* This filter allows you to alter the data structure sent for the CEU credit report API.
* For instance, you might want to add a custom field or reformat an existing one.
*
* @param array $api_setup The current API setup data.
* @param object $this The instance of the course-report object.
* @return array The modified API setup data.
*/
add_filter( 'uo_ceu_credit_report_api_data', function( $api_setup, $this_obj ) {
// Let's add a custom flag to indicate if the user has completed all required CEU courses.
// This is just an illustrative example; actual logic would depend on your needs.
if ( isset( $api_setup['user_id'] ) && ! empty( $api_setup['user_id'] ) ) {
// In a real scenario, you'd fetch data to determine completion status.
// For this example, we'll just add a placeholder.
$api_setup['custom_flags']['all_ceu_completed'] = true; // Assume true for demo
}
// You could also reformat existing data. For example, changing the language of a button.
if ( isset( $api_setup['language'] ) && is_array( $api_setup['language'] ) ) {
$api_setup['language']['next'] = __( 'Proceed', 'my-custom-textdomain' );
}
return $api_setup;
}, 10, 2 );
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/classes/course-report.php:433
'next' => _x( 'Next', 'DataTables pagination', 'uncanny-ceu' ),
'previous' => _x( 'Previous', 'DataTables pagination', 'uncanny-ceu' ),
),
),
),
);
return apply_filters( 'uo_ceu_credit_report_api_data', $api_setup, $this );
}
////////////////////////////////////////
//
// Property setter functions
//
////////////////////////////////////////