Filter uncanny-learndash-groups

ulgm_subscription_additional_seats_learn_more

Filters the "Learn More" link for additional subscription seats, allowing customization of the link's content.

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

Description

This filter allows you to modify the "Learn More" link for additional seats when WooCommerce is active and the group is not downgraded or upgraded. Developers can alter the link's appearance or URL to point to custom resources or information about seat purchases. It primarily affects frontend display.


Usage

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

Return Value

The filtered value.


Examples

/**
 * Modify the 'learn more' link for additional seats in WooCommerce subscriptions.
 *
 * This filter allows developers to customize the HTML output for the 'learn more'
 * icon when additional seats are being added to a group that is part of a
 * WooCommerce subscription.
 *
 * @param string $learn_more The default HTML for the 'learn more' icon (e.g., '<span class="dashicons dashicons-external"></span>').
 * @return string The modified HTML for the 'learn more' icon.
 */
add_filter( 'ulgm_subscription_additional_seats_learn_more', function( $learn_more ) {
	// Check if WooCommerce subscriptions are active and if this is a subscription group.
	if ( Utilities::if_woocommerce_active() && Utilities::if_woocommerce_subscription_active() ) {
		// Access the current managed group ID. Assuming this is available globally or passed in context.
		// For this example, we'll assume GroupManagementInterface::$ulgm_current_managed_group_id is accessible.
		global $post; // WordPress global post object
		$group_id = $post->ID ?? GroupManagementInterface::$ulgm_current_managed_group_id; // Fallback for context

		if ( ! empty( $group_id ) && 'yes' === get_post_meta( $group_id, '_uo_subscription_group', true ) ) {
			// Conditionally modify the icon or add custom styling.
			// For example, we might want to change the icon color or add a tooltip.
			// Here, we'll just add a simple tooltip for demonstration.
			$learn_more = str_replace( '<span', '<span title="Learn more about adding seats for subscriptions"', $learn_more );
		}
	}
	return $learn_more;
}, 10, 1 );

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/templates/frontend-uo_groups/users-table-actions.php:177
src/classes/woocommerce/woocommerce-modify-group.php:397

if ( Utilities::if_woocommerce_active() && empty( get_post_meta( GroupManagementInterface::$ulgm_current_managed_group_id, SharedFunctions::$code_group_downgraded, true ) ) && empty( get_post_meta( GroupManagementInterface::$ulgm_current_managed_group_id, '_ulgm_is_upgraded', true ) ) && empty( get_post_meta( GroupManagementInterface::$ulgm_current_managed_group_id, '_ulgm_is_custom_group_created', true ) ) ) {
					$add_seats_link = GroupManagementInterface::$ulgm_management_shortcode['text']['add_seats_link'];
					$lm             = '';
					$show_button    = true;
					if ( Utilities::if_woocommerce_subscription_active() && 'yes' === get_post_meta( GroupManagementInterface::$ulgm_current_managed_group_id, '_uo_subscription_group', true ) ) {
						if ( class_exists( 'uncanny_learndash_groupsWoocommerceLicenseSubscription' ) && WoocommerceLicenseSubscription::is_woo_subscriptions_add_seats_enabled() ) {
							$learn_more_link = apply_filters( 'ulgm_subscription_additional_seats_learn_more_link', get_option( 'woo_subscription_allow_additional_seats_learn_more_link', '' ), array() );
							$learn_more      = apply_filters( 'ulgm_subscription_additional_seats_learn_more', '<span class="dashicons dashicons-external"></span>' );
							if ( ! empty( $learn_more_link ) ) {
								$lm = sprintf( '<a href="%s" target="_blank">%s</a>', $learn_more_link, $learn_more );
							}
							$add_seats_link = "$add_seats_link&is_subscription_group=yes";
						} else {
							$show_button = false;
						}


Scroll to Top