Filter uncanny-learndash-groups

ulgm_user_search_minimum_input_length

Filters the minimum number of characters a user must type to initiate a search.

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

Description

Filters the minimum character input length required to trigger a user search in the Uncanny LearnDash Groups reports. Developers can modify this value to adjust when the search functionality becomes active, improving performance or user experience. Defaults to 3 characters.


Usage

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

Return Value

The filtered value.


Examples

/**
 * Adjust the minimum input length for the user search in the Uncanny Groups Manager reports.
 *
 * By default, the search requires at least 3 characters. This filter allows
 * developers to change this value if needed, for example, to make the search
 * more sensitive or less sensitive.
 *
 * @param int $minimum_input_length The default minimum input length.
 * @return int The new minimum input length for the user search.
 */
add_filter( 'ulgm_user_search_minimum_input_length', function( $minimum_input_length ) {
	// Example: Increase the minimum input length to 4 characters.
	// This would require users to type at least 4 characters before the search
	// starts fetching results, potentially reducing unnecessary queries for short inputs.
	$new_minimum_length = 4;

	// You could also make this dynamic, for example, based on a user role or option.
	// For instance, if a specific option is set in the WordPress admin:
	// $option_value = get_option( 'ulgm_custom_search_min_length' );
	// if ( ! empty( $option_value ) && is_numeric( $option_value ) ) {
	//     $new_minimum_length = absint( $option_value );
	// }

	return $new_minimum_length;
}, 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/classes/reports/learndash-progress-report.php:1786

'searching'            => _x( 'Searching…', 'ulgm user search', 'uncanny-learndash-groups' ),
					'placeholder'          => _x( 'Search by user ID, name, email address or key', 'ulgm user search', 'uncanny-learndash-groups' ),
				),
				'selectors'          => array(
					'searchField' => '#ulg-manage-progress-user-search-field',
					'wrapper'     => '.ulg-manage-progress-user-search-field-wrapper',
				),
				'minimumInputLength' => apply_filters( 'ulgm_user_search_minimum_input_length', 3 ),
			)
		);

		wp_enqueue_script( 'ulgm-user-search' );
	}

	/**

Scroll to Top