Filter uncanny-continuing-education-credits

uo_tincanny_reporting_do_ceu_override

Filters whether to force a CEU calculation or allow the default behavior when reporting.

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

Description

Filters whether to perform CEU reporting for Tincanny quiz results. By default, it's enabled. Developers can return `false` to disable CEU reporting entirely, preventing the processing of quiz completion data for CEU credits.


Usage

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

Return Value

The filtered value.


Examples

// Example: Prevent CEU reporting for specific quiz IDs.
add_filter( 'uo_tincanny_reporting_do_ceu_override', 'my_prevent_ceu_reporting_for_specific_quizzes', 10, 1 );

/**
 * Prevents CEU reporting for specific quiz IDs.
 *
 * This function hooks into the 'uo_tincanny_reporting_do_ceu_override' filter.
 * If the current quiz ID is in a predefined list of excluded IDs, it will return false,
 * effectively disabling CEU reporting for that quiz.
 *
 * @param bool $do_ceu Whether to perform CEU reporting.
 * @return bool       False to prevent CEU reporting, true otherwise.
 */
function my_prevent_ceu_reporting_for_specific_quizzes( $do_ceu ) {
    // Ensure we're only acting if the default is to do CEU reporting.
    if ( ! $do_ceu ) {
        return $do_ceu;
    }

    // Get the current quiz ID from the URL parameter.
    $current_quiz_id = ( isset( $_GET['quiz-id'] ) && 0 !== absint( $_GET['quiz-id'] ) ) ? absint( $_GET['quiz-id'] ) : 0;

    // Define a list of quiz IDs for which CEU reporting should be skipped.
    $excluded_quiz_ids = array( 123, 456, 789 ); // Replace with actual quiz IDs.

    // Check if the current quiz ID is in the exclusion list.
    if ( in_array( $current_quiz_id, $excluded_quiz_ids, true ) ) {
        // If it's an excluded quiz, return false to prevent CEU reporting.
        return false;
    }

    // Otherwise, return the original value (true in this context) to allow CEU reporting.
    return $do_ceu;
}

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/ceu-tincanny-question-analysis.php:56

add_action( 'plugins_loaded', array( $this, 'multiple_filters' ), 99 );
	}

	/**
	 * @return void
	 */
	public function multiple_filters() {
		if ( false === apply_filters( 'uo_tincanny_reporting_do_ceu_override', true ) ) {
			return;
		}

		$quiz_id = ( isset( $_GET['quiz-id'] ) && 0 !== $_GET['quiz-id'] ) ? absint( $_GET['quiz-id'] ) : 0;

		$skip_quiz_ids = apply_filters( 'uo_tincanny_reporting_skip_ceu_override_quiz_ids', array(), $quiz_id );


Scroll to Top