ulgm_progress_report_wpml_suppress_filters
Filters whether WPML filters should be suppressed for the ULGM progress report query.
add_filter( 'ulgm_progress_report_wpml_suppress_filters', $callback, 10, 1 );
Description
Filters the `suppress_filters` query variable when integrating with WPML for progress reports. Developers can use this to conditionally disable WPML's translation filters for queries related to progress reports, ensuring accurate data retrieval across languages. It fires within the `wpml_suppress_filters` method before the query is executed.
Usage
add_filter( 'ulgm_progress_report_wpml_suppress_filters', 'your_function_name', 10, 1 );
Parameters
-
$wp_query(mixed) - This parameter controls whether WPML filters should be suppressed when generating the progress report.
Return Value
The filtered value.
Examples
add_filter( 'ulgm_progress_report_wpml_suppress_filters', 'my_custom_ulgm_wpml_suppress_filters', 10, 2 );
/**
* Conditionally suppress WPML filters for LearnDash progress reports.
*
* This function provides a way to programmatically control whether WPML's
* translation filters are applied when generating LearnDash progress reports.
* For example, you might want to disable these filters when a specific user
* role is viewing the report to ensure accurate, non-translated data.
*
* @param bool $suppress_filters The current value of suppress_filters (true by default).
* @param WP_Query $wp_query The current WP_Query object.
* @return bool The modified value of suppress_filters.
*/
function my_custom_ulgm_wpml_suppress_filters( $suppress_filters, $wp_query ) {
// Check if the current user has a specific role, e.g., 'administrator'.
if ( current_user_can( 'manage_options' ) ) {
// If the user can manage options (e.g., an administrator),
// we might want to bypass WPML filters to get raw data.
return false; // Suppress WPML filters
}
// Otherwise, return the original value, allowing WPML filters to be applied.
return $suppress_filters;
}
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:2335
public static function wpml_suppress_filters( $wp_query ) {
if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
$wp_query->query_vars['suppress_filters'] = apply_filters( 'ulgm_progress_report_wpml_suppress_filters', true, $wp_query );
}
}