uo_report_menu_items
Filters the report menu items displayed in the admin area, allowing for customization of the progress report button.
add_filter( 'uo_report_menu_items', $callback, 10, 2 );
Description
This filter hook allows developers to modify the report menu items displayed in the user management table. It provides access to the existing report menu items and a progress report button, enabling customization of menu content and functionality for reporting purposes.
Usage
add_filter( 'uo_report_menu_items', 'your_function_name', 10, 2 );
Parameters
-
$report_menu_items(mixed) - This parameter contains the array of menu items that will be displayed in the report menu.
-
$progress_report_button(mixed) - This parameter contains an array of menu items that will be displayed in the report menu.
Return Value
The filtered value.
Examples
<?php
/**
* Example function to modify the report menu items.
* This function might add or remove specific report buttons based on certain conditions.
*
* @param array $report_menu_items An array containing the existing report menu items (likely HTML strings of buttons).
* @param array $report_button_data An array containing data for various report buttons like progress, quiz, etc.
* @return array The modified array of report menu items.
*/
function my_custom_report_menu_items( $report_menu_items, $report_button_data ) {
// Example: Conditionally remove the 'quiz_report_button' if it exists
// and if the current user is not an administrator.
if ( isset( $report_button_data['quiz_report_button'] ) && ! current_user_can( 'manage_options' ) ) {
// Find the index of the quiz report button and remove it.
foreach ( $report_menu_items as $key => $item ) {
// This is a simplistic check; a more robust check might involve parsing HTML or using specific IDs/classes.
if ( strpos( $item, 'quiz-report-button-class' ) !== false ) {
unset( $report_menu_items[ $key ] );
break; // Assume only one instance
}
}
}
// Example: Add a new custom report button under specific circumstances.
// Let's say we want to add a 'custom_analytics_report' button if a specific option is enabled.
if ( get_option( 'my_plugin_enable_custom_analytics' ) === 'yes' ) {
$custom_button_html = '<button type="button" class="custom-analytics-report-button">Custom Analytics Report</button>';
// Add the new button to the end of the array.
$report_menu_items[] = $custom_button_html;
}
// Always return the modified array of menu items.
return $report_menu_items;
}
add_filter( 'uo_report_menu_items', 'my_custom_report_menu_items', 10, 2 );
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:676
type="button"
tabindex="0">
' . GroupManagementInterface::$ulgm_management_shortcode['text']['group_essay_page'] . '
</button>';
}
// Allow 3rd parties to adjust report menu items.
$report_menu_items = apply_filters(
'uo_report_menu_items',
$report_menu_items,
array(
'progress_report_button' => $progress_report_button,
'quiz_report_button' => $quiz_report_button,
'progress_management_report_button' => $progress_management_report_button,
'assignment_button' => $assignment_button,