Action tin-canny-learndash-reporting

tincanny_reporting_user_report_before_end

Fires before the user report is finalized, allowing for modifications to the report content.

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

Description

Fires just before the user report table ends. Developers can use this action to add custom content or modify the report's final output. It's a prime spot for post-report summaries, custom actions, or additional data visualizations related to the user's progress within Tincanny.


Usage

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

Examples

<?php
/**
 * Add a custom message or element before the Tincanny user report table ends.
 *
 * This example appends a simple message to the report.
 *
 * @param int $user_id The ID of the user for whom the report is being generated.
 * @param array $report_data The associative array containing the user's report data.
 */
add_action( 'tincanny_reporting_user_report_before_end', function( $user_id, $report_data ) {
    // This hook fires before the closing tags of the user report tab's main container.
    // We can use this to output additional information or modify the report output.

    if ( ! current_user_can( 'manage_options' ) ) {
        // Only show this to administrators for example purposes.
        return;
    }

    ?>
    <div class="tincanny-custom-report-section">
        <h3>Custom Report Information</h3>
        <p>This report was generated for user ID: <strong><?php echo esc_html( $user_id ); ?></strong>.</p>
        <p>
            Number of courses completed:
            <strong><?php echo count( $report_data['courses'] ?? [] ); ?></strong>.
        </p>
        <p>
            Total time spent on courses (approx):
            <strong><?php echo esc_html( $report_data['total_time'] ?? 'N/A' ); ?></strong>.
        </p>
    </div>
    <?php
}, 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/reporting/learndash/templates/user-report-tab.php:308

</table>
			        </div>
				</div>
			</div>
		</div>
	</div>

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

</div>

Scroll to Top