Filter uncanny-learndash-groups

group_reporting_transcript_url

Filters the URL for the group reporting transcript, allowing modification before it's retrieved.

add_filter( 'group_reporting_transcript_url', $callback, 10, 2 );

Description

Filters the URL for the group reporting transcript page. Developers can modify this URL to point to a different page or add custom query parameters. The hook fires when the transcript page permalink is being generated. The original page ID is passed for context.


Usage

add_filter( 'group_reporting_transcript_url', 'your_function_name', 10, 2 );

Parameters

$request (mixed)
This parameter contains the request data from the user's submission, which may include parameters like 'transcript-page-id'.
$request (mixed)
This parameter holds the current request data, which is an array containing various query parameters for generating the group report.

Return Value

The filtered value.


Examples

/**
 * Modify the transcript URL for group reporting.
 *
 * This function demonstrates how to intercept and potentially modify the
 * permalink of a transcript page used in group reporting. For example,
 * you might want to append a query parameter to track where the user came from.
 *
 * @param string $transcript_url The original permalink of the transcript page.
 * @param int    $post_id        The ID of the transcript post.
 * @return string The modified or original transcript URL.
 */
function my_custom_group_reporting_transcript_url( $transcript_url, $post_id ) {
	// Append a UTM parameter to track the source if it's a specific group report.
	// This assumes you have some way to identify the context within the $request object
	// that is available in the scope where the filter is applied.
	// For this example, we'll simulate checking for a hypothetical 'group_id' in the request.
	// In a real scenario, you'd need to ensure $request is accessible or passed differently.

	// Hypothetically check if we are in a context where we need to add parameters.
	// You would replace this with your actual logic to determine if these parameters are relevant.
	if ( isset( $_GET['group_id'] ) && $_GET['group_id'] > 0 ) {
		$utm_source = 'group-report-' . sanitize_text_field( $_GET['group_id'] );
		$transcript_url = add_query_arg( 'utm_source', $utm_source, $transcript_url );
	}

	return $transcript_url;
}
add_filter( 'group_reporting_transcript_url', 'my_custom_group_reporting_transcript_url', 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/classes/reports/group-reports-interface.php:325

if ( empty( self::$table_columns ) ) {
			self::$table_columns = $allowed_columns;
		}

		// Check if we have a valid post ID
		if ( ! empty( $request['transcript-page-id'] ) && $request['transcript-page-id'] !== 0 ) {
			// Get the permalink of the transcript
			self::$transcript_page_url = apply_filters(
				'group_reporting_transcript_url',
				get_permalink( $request['transcript-page-id'] ),
				$request['transcript-page-id']
			);
		}

		// Create object with inline data

Scroll to Top