ulgm_group_name_text
Filters the text used for displaying the group name, allowing for customization of the default "Group Name" label.
add_filter( 'ulgm_group_name_text', $callback, 10, 1 );
Description
This filter allows developers to modify the default text displayed for the "Group Name" field on product pages. You can use this hook to change the label to something more specific or to internationalize the text. The hook fires before the group name field is rendered, offering flexibility in customizing its appearance.
Usage
add_filter( 'ulgm_group_name_text', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
add_filter( 'ulgm_group_name_text', 'my_custom_group_name_label', 10, 1 );
/**
* Customizes the default "Group Name" label displayed on the product page.
*
* This function demonstrates how to modify the text used for the group name field.
*
* @param string $original_label The original label text.
* @return string The modified label text.
*/
function my_custom_group_name_label( $original_label ) {
// For example, let's prepend a prefix to the group name label.
// This could be useful if you have multiple plugins adding group name fields
// and want to visually distinguish them.
return 'My LMS Group: ' . $original_label;
}
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/woocommerce/woocommerce-license.php:1937
src/classes/woocommerce/woocommerce-license.php:2066
public function add_group_name_field() {
if ( WoocommerceModifyGroup::is_modifying_license() ) {
return;
}
if ( apply_filters( 'ulgm_hide_group_name_field_on_product_page', false ) ) {
return;
}
if ( 'yes' === get_option( 'ulgm_hide_group_name_fields_on_product_page', 'no' ) ) {
return;
}
global $product;
if ( false === self::is_license_or_subscription_license( $product ) ) {
return;
}
echo '<div class="group-name-field">';
echo '<label for="ulgm_group_name">' . apply_filters( 'ulgm_group_name_text', esc_attr__( 'Group Name', 'uncanny-learndash-groups' ) ) . '</label>';
echo '<input type="text" id="ulgm_group_name" name="ulgm_group_name" />';
echo '</div>';
}