Action tin-canny-learndash-reporting

tincanny_reporting_before_content

Fires before the main content of a report is displayed, allowing for custom modifications.

add_action( 'tincanny_reporting_before_content', $callback, 10, 1 );

Description

Fires before the main content area of the Tincanny reporting interface loads. Developers can use this hook to inject custom elements, modify existing content, or perform actions immediately before the reporting sections are displayed. It runs within the core reporting template.


Usage

add_action( 'tincanny_reporting_before_content', 'your_function_name', 10, 1 );

Examples

<?php
/**
 * Example function to add a custom message before the reporting content.
 * This demonstrates how to hook into 'tincanny_reporting_before_content'
 * to inject custom HTML or logic.
 */
add_action( 'tincanny_reporting_before_content', 'my_custom_tincanny_report_message', 10 );

/**
 * Inserts a custom message or disclaimer before the main reporting content.
 *
 * @param array $args An array of arguments passed to the action hook.
 *                    (Although this hook doesn't currently pass specific args,
 *                    it's good practice to accept them if the hook might evolve.)
 */
function my_custom_tincanny_report_message( $args = [] ) {
    // Check if we are in a specific report context that requires a disclaimer.
    // For demonstration, let's assume we want to add a note when viewing the 'xapi_quiz' report.
    // In a real scenario, you might check $_GET parameters or other global variables.

    // Get the current report type if available. This is a hypothetical check.
    // You'd need to inspect the actual context where the hook is fired to know
    // what relevant information might be available.
    $current_report_type = isset( $_GET['report_type'] ) ? sanitize_text_field( $_GET['report_type'] ) : '';

    if ( 'xapi_quiz' === $current_report_type ) {
        ?>
        <div class="tincanny-custom-notice" style="background-color: #e7f3fe; border-left: 6px solid #2196F3; padding: 10px; margin-bottom: 20px;">
            <p><strong>Important Note:</strong> The xAPI Quiz data below represents learner interactions and may include specific question responses and outcomes.</p>
        </div>
        <?php
    }

    // You could also add dynamic content based on user roles, permissions, etc.
    // For example:
    // if ( current_user_can( 'manage_options' ) ) {
    //     echo '<p>Admin view: Additional debugging information might be available.</p>';
    // }
}

// If this were a filter hook, it would look like this:
/*
add_filter( 'tincanny_reporting_some_filter', 'my_custom_tincanny_filter_logic', 10, 2 );

function my_custom_tincanny_filter_logic( $data_to_filter, $additional_param ) {
    // Perform some modification on $data_to_filter based on $additional_param
    $modified_data = array_map( function( $item ) {
        // Example: Add a prefix to each item
        return 'processed_' . $item;
    }, $data_to_filter );

    return $modified_data; // Always return the modified data
}
*/

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/reporting/xapi-quiz/xapi-quiz-report.php:40
src/reporting/tin-can/tin-can-report.php:40
src/shortcode-tincanny/frontend.php:35
src/reporting/learndash/templates/course-user-wrapper.php:29

<?php do_action( 'tincanny_reporting_wrapper_after_begin' ); ?>

					<section id="first-tab-group" class="uo-admin-reporting-tabgroup">

						<?php

						do_action( 'tincanny_reporting_before_content' );
						if ( ! ultc_filter_has_var( 'tc_filter_mode' ) ) {
							?>
							<div class="tincanny-tin-canny-error">
								<p><?php _e( 'Please select your criteria to filter the xAPI Quiz data', 'uncanny-learndash-reporting' ); ?></p>
							</div>
							<?php
						} else {


Scroll to Top