Filter Uncanny Redemption Codes

ulc_codes_group_columns

Filters the columns displayed in the user list customizer codes group for integration.

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

Description

Filters the array of columns displayed in the Uncanny Codes admin "Groups" view. Developers can add, remove, or reorder columns to customize the table output for batch code management. This hook fires before the columns are rendered, allowing extensive control over the displayed data.


Usage

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

Parameters

$columns (mixed)
This parameter contains an array of column definitions for the groups table.

Return Value

The filtered value.


Examples

/**
 * Example of adding a custom column to the Uncanny LearnDash Codes "Groups" table.
 *
 * This function demonstrates how to hook into the 'ulc_codes_group_columns' filter
 * to add, remove, or reorder columns displayed in the Uncanny LearnDash Codes
 * "Groups" administration screen.
 *
 * @param array $columns An associative array of existing columns.
 * @return array The modified array of columns.
 */
function my_custom_ulc_codes_group_columns( $columns ) {

	// Example: Add a new column for "Associated Course" after "Type".
	// We find the key for 'code_for' and insert our new column after it.
	$new_columns = array();
	foreach ( $columns as $key => $column_label ) {
		$new_columns[ $key ] = $column_label;
		if ( $key === 'code_for' ) {
			// Add our custom column. You would then need to add corresponding
			// logic in the 'ulc_render_group_column' filter to display content
			// for this new column.
			$new_columns['associated_course'] = esc_html__( 'Course', 'my-text-domain' );
		}
	}

	// Example: Remove the "Cancelled" column.
	if ( isset( $new_columns['cancelled'] ) ) {
		unset( $new_columns['cancelled'] );
	}

	// Example: Reorder columns - move "Dates" to be the first column.
	if ( isset( $new_columns['timeline'] ) ) {
		$timeline_data = array( 'timeline' => $new_columns['timeline'] );
		unset( $new_columns['timeline'] );
		$new_columns = array_merge( $timeline_data, $new_columns );
	}

	return $new_columns;
}
add_filter( 'ulc_codes_group_columns', 'my_custom_ulc_codes_group_columns', 10, 1 ); // 10 is the priority, 1 is the number of accepted arguments.

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/admin/class-view-groups.php:72

public function get_columns() {
		$columns = array(
			'group_name'   => esc_html__( 'Batch', 'uncanny-learndash-codes' ),
			'code_for'     => esc_html__( 'Type', 'uncanny-learndash-codes' ),
			'timeline'     => esc_html__( 'Dates', 'uncanny-learndash-codes' ),
			'used_count'   => esc_html__( 'Code Usage', 'uncanny-learndash-codes' ),
			'cancelled'    => esc_html__( 'Cancelled', 'uncanny-learndash-codes' ),
			'action'       => esc_html__( 'Actions', 'uncanny-learndash-codes' ),
		);

		return apply_filters( 'ulc_codes_group_columns', $columns );
	}


Scroll to Top