Filter Dynamic Uncanny Redemption Codes

ulc_codes_group_row_{dynamic}

> **Note:** This is a dynamic hook. The actual hook name is constructed at runtime. Filters a row's data before it's displayed in a grouped list. This hook runs for each row within a group.

add_filter( 'ulc_codes_group_row_{dynamic}', $callback, 10, 2 );

Description

Fires after a table row (`

`) is generated for a specific group in the Uncanny Codes admin table. Developers can modify the `$row` content to customize the displayed information for each group row, before it's outputted.


Usage

add_filter( 'ulc_codes_group_row_{dynamic}', 'your_function_name', 10, 2 );

Parameters

$row (mixed)
This parameter contains the HTML markup for the current row being generated for the group of codes.
$group (mixed)
This parameter contains the current HTML string being built for a single row in the Uncanny Codes group listing table.

Return Value

The filtered value.


Examples

<?php
/**
 * Example of how to hook into the ulc_codes_group_row_{dynamic} filter.
 *
 * This example demonstrates adding an extra column to the group row in the Uncanny LearnDash Codes admin table.
 * It specifically targets the 'name' column.
 *
 * @param string $row The current HTML string for the row.
 * @param object $group The group object being processed.
 * @return string The modified HTML string for the row.
 */
add_filter( 'ulc_codes_group_row_name', function( $row, $group ) {
    // Assuming $group has a property like 'course_id' that we want to display.
    // This is a hypothetical property and you'll need to adapt it based on the actual $group object structure.
    $course_title = 'N/A';
    if ( isset( $group->course_id ) && $group->course_id > 0 ) {
        $course_object = get_post( $group->course_id );
        if ( $course_object ) {
            $course_title = esc_html( $course_object->post_title );
        }
    }

    // Append the new column's content to the existing row HTML.
    // We're adding a simple column displaying the associated course title.
    $row .= '<td class="ulc-column-course-title">' . $course_title . '</td>';

    return $row;
}, 10, 2 ); // 10 is the priority, 2 is the number of arguments the callback accepts.

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:254

)
					)
				) . '" data-tooltip="' . esc_attr__( 'Delete', 'uncanny-learndash-codes' ) . '" data-tooltip-size="sm"><span class="dashicons dashicons-trash"></span></a>';

				$row .= implode( ' ', $actions );
				break;
				default:
					$row .= apply_filters( 'ulc_codes_group_row_' . $column_name, $row, $group );
					break;
			}
			$row .= '</td>';
		}

		$row = apply_filters( 'ulc_codes_group_row', $row, $group );
		$row .= '</tr>';


Scroll to Top