Filter uncanny-continuing-education-credits

uo_ceu_credit_report_data_mode

Filters the mode used for retrieving CEU credit report data, defaulting to 'meta'.

add_filter( 'uo_ceu_credit_report_data_mode', $callback, 10, 1 );

Description

Fires to determine the data retrieval mode for CEU credit reports, defaulting to 'meta'. Developers can filter this hook to change the report mode, for example, to retrieve data from a custom source or alter the default 'meta' behavior.


Usage

add_filter( 'uo_ceu_credit_report_data_mode', 'your_function_name', 10, 1 );

Return Value

The filtered value.


Examples

/**
 * Example: Change the default CEU credit report mode from 'meta' to 'database'.
 *
 * This filter allows you to override the default method for retrieving CEU credit report data.
 * By default, it uses the value stored in the 'ceu_report_mode' option, which defaults to 'meta'.
 * This example demonstrates how to programmatically change it to 'database'.
 *
 * @param string $report_mode The current report mode, defaulting to 'meta'.
 * @return string The modified report mode.
 */
add_filter( 'uo_ceu_credit_report_data_mode', function( $report_mode ) {
	// We want to force the report mode to 'database' if it's not already set to something else.
	// This could be useful if you've migrated your data to a new database structure
	// and want to ensure the system uses the new structure for reporting.
	if ( $report_mode === 'meta' ) {
		return 'database';
	}

	// Otherwise, keep the existing mode.
	return $report_mode;
}, 10, 1 );

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:1428

public function get_mode() {
		if ( empty( $this->mode ) ) {
			$this->mode = apply_filters( 'uo_ceu_credit_report_data_mode', get_option( 'ceu_report_mode', 'meta' ) );
		}
		return $this->mode;
	}

Scroll to Top