Filter tin-canny-learndash-reporting

tincan_xapi_table_columns

Filters the columns displayed in the xAPI tables for customization.

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

Description

Filters the columns displayed in the xAPI tables. Developers can add, remove, or modify table columns to customize the data presented to users. This hook fires after the default columns are determined, allowing for dynamic adjustments.


Usage

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

Parameters

$columns (mixed)
This parameter contains an array of column definitions for the xAPI table, which can be filtered to modify the displayed columns.

Return Value

The filtered value.


Examples

<?php
/**
 * Example of adding a custom column to the xAPI table.
 *
 * This example adds a new column titled "Custom Status" which will display
 * "Active" if the 'status' value within the column data is 'completed',
 * and "Inactive" otherwise.
 *
 * @param array $columns The existing array of table columns.
 * @return array The modified array of table columns.
 */
add_filter( 'tincan_xapi_table_columns', 'my_custom_xapi_table_columns', 10, 1 );

function my_custom_xapi_table_columns( $columns ) {
    // Let's assume we want to add our custom column after the 'Verb' column.
    // We'll need to find the index of the 'Verb' column to insert ours correctly.
    $verb_index = array_search( 'Verb', $columns );

    if ( $verb_index !== false ) {
        // Insert our new column label after the 'Verb' column.
        // The actual data for this column will be handled by a separate
        // filter (likely 'tincan_xapi_table_column_data') or within the
        // plugin's rendering logic based on the column label.
        array_splice( $columns, $verb_index + 1, 0, array( 'Custom Status' ) );
    } else {
        // If 'Verb' column isn't found, just append our new column.
        $columns[] = 'Custom Status';
    }

    return $columns;
}
?>

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/shortcode-tincanny/shortcode-tincanny.php:1730

} else {
					if ( true === $column['value'] ) {
						$columns[] = $column['label'];
					}
				}
			}

			$columns = apply_filters( 'tincan_xapi_table_columns', $columns );

		} else {

			add_filter( 'tincan_table_columns', array( __CLASS__, 'tincan_remove_success_column' ), 10 );

			$columns = apply_filters(
				'tincan_table_columns',


Scroll to Top