ulgm_multiple_add_users_error_separator
Filters the separator used between multiple user add error messages.
add_filter( 'ulgm_multiple_add_users_error_separator', $callback, 10, 1 );
Description
Allows modification of the separator used between multiple error messages when adding users in bulk. Developers can change this to a different string or HTML element to customize error display, impacting how validation errors are presented to the user.
Usage
add_filter( 'ulgm_multiple_add_users_error_separator', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Example of using the 'ulgm_multiple_add_users_error_separator' filter.
* This example changes the error separator to a more visually distinct
* "---" when multiple users are added to a group and errors occur.
*/
add_filter( 'ulgm_multiple_add_users_error_separator', 'my_custom_ulgm_error_separator', 10, 1 );
/**
* Custom function to modify the error separator for bulk user addition.
*
* @param string $default_separator The default separator provided by the plugin.
* @return string The custom separator to use.
*/
function my_custom_ulgm_error_separator( $default_separator ) {
// Check if there are any errors to justify a more prominent separator.
// In a real scenario, you might have access to error variables here
// if the filter allowed more parameters, or you could try to access
// global error states if appropriate and documented. For this example,
// we'll assume we always want to use the custom separator for demonstration.
// If the default separator is indeed a line break, we might want to replace it.
// Otherwise, we'll stick to the default or another custom logic.
if ( '<br /> ' === $default_separator ) {
return '<br /> --- <br /> '; // A more visually distinct separator.
}
// If the default separator is something else, or we don't want to override it,
// return the original.
return $default_separator;
}
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/group-management/management-group-multi-add-users.php:152
}
}
}
$url = SharedFunctions::get_group_management_page_id( true );
$url .= '?group-id=' . $group_id;
$url .= '&bulk=1';
$separator = apply_filters( 'ulgm_multiple_add_users_error_separator', '<br /> ' );
if ( ! empty( $password_length_warnings ) ) {
$error_results = array_merge( $password_length_warnings, $error_results );
}
if ( ! empty( $error_results ) ) {
$url .= '&bulk-errors=' . urlencode( join( $separator, $error_results ) );
}
if ( ! empty( $insert_results ) ) {