Filter uncanny-learndash-groups

ulgm_group_course_report_shortcode_attributes

Filters the attributes used for the group course report shortcode before it's rendered on the page.

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

Description

Filters the attributes used by the `ulgm_group_course_report` shortcode. Developers can modify these attributes, such as `order_column`, `csv_export_button`, and `excel_export_button`, before the shortcode renders, allowing for customization of report display and export options.


Usage

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

Parameters

$request (mixed)
This parameter contains an array of attributes used to customize the output and functionality of the group course report shortcode, including sorting order and export button visibility.

Return Value

The filtered value.


Examples

add_filter( 'ulgm_group_course_report_shortcode_attributes', 'my_custom_group_course_report_attributes', 10, 1 );

/**
 * Customizes attributes for the group course report shortcode.
 *
 * This function demonstrates how to modify the default attributes
 * passed to the group course report shortcode. In this example,
 * we're changing the default order to ascending for the 'course-order'
 * and ensuring the CSV export button is always shown.
 *
 * @param array $request The array of shortcode attributes.
 * @return array The modified array of shortcode attributes.
 */
function my_custom_group_course_report_attributes( $request ) {
    // Set a default for 'course-order' if it's not already set, and make it ascending.
    if ( ! isset( $request['course-order'] ) || empty( $request['course-order'] ) ) {
        $request['course-order'] = 'asc';
    }

    // Ensure the CSV export button is always shown, overriding any other setting.
    $request['csv_export_button'] = 'show';

    return $request;
}

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/reports/group-reports-interface.php:271

'order_column'        => 'desc',
				// Designates the ascending or descending order of the ‘orderby‘ parameter
				'csv_export_button'   => 'show',
				'excel_export_button' => 'show',
			),
			$attributes
		);
		$request    = apply_filters( 'ulgm_group_course_report_shortcode_attributes', $request );

		// Clean the transcript page ID
		$request['transcript-page-id'] = absint( $request['transcript-page-id'] );

		self::$course_order = $request['course-order'];

		if ( ulgm_filter_has_var( 'user-id' ) ) {


Scroll to Top