uo_admin_import_users_template
Filters the HTML template used for the admin import users page.
add_filter( 'uo_admin_import_users_template', $callback, 10, 1 );
Description
Filters the HTML template used for the admin page where users are imported from CSV. Developers can modify this to customize the import form's appearance or functionality. This filter fires during the initialization of the admin import module.
Usage
add_filter( 'uo_admin_import_users_template', 'your_function_name', 10, 1 );
Parameters
-
$template(mixed) - This parameter contains the path to the template file used to display the user import interface in the WordPress admin area.
Return Value
The filtered value.
Examples
/**
* Example filter to modify the admin import users template.
* This example adds a custom notice at the top of the import form.
*
* @param string $template The original template path.
* @return string The modified template path.
*/
add_filter(
'uo_admin_import_users_template',
function ( $template ) {
// Check if the current template is the one we want to modify.
// This is a basic check; a more robust solution might involve checking
// the contents of the template or using other context.
if ( str_contains( $template, 'admin-import-users.php' ) ) {
// For demonstration purposes, let's assume we are injecting HTML
// directly into the template file. In a real-world scenario,
// you might want to return a different template file that already
// includes your modifications, or modify the template content dynamically.
//
// Since the hook is applied to the $template variable which is a path,
// it's more likely that a developer would provide an alternative template path.
// For this example, we'll simulate modifying the content by returning a new path.
//
// In a real plugin, you would likely have a custom template file
// that includes your modifications. For example:
// $custom_template_path = plugin_dir_path( __FILE__ ) . 'templates/my-custom-admin-import-users.php';
// return $custom_template_path;
// As a simpler example, let's return the original template path and assume
// the template file itself can be modified or hooks within it can be used.
// If the intention is to inject content, a different hook might be more appropriate,
// or the template itself would need to be re-rendered with modifications.
// For the sake of demonstrating a return value for the filter, we'll just
// return the original template path. A real modification would involve
// either creating a new template file and returning its path, or using
// a different hook if the filter is designed to alter content rather than the path.
// If the filter was intended to modify the content of the template,
// the original code might look more like:
// $template_content = file_get_contents( $template );
// $custom_notice = '<div class="notice notice-info"><p><strong>Important:</strong> Please review the import settings carefully.</p></div>';
// $template_content = $custom_notice . $template_content;
// return $template_content; // But the hook is applied to $template, which is a path.
// Therefore, the most realistic use case for this filter, given it modifies
// the `$template` variable which is a file path, is to return a different template file.
// Since we don't have a custom template file to link to in this isolated example,
// we'll just return the original path, assuming the developer would replace this
// with their custom template path if they had one.
// Example of returning a different template path:
// $my_custom_template_path = trailingslashit( plugin_dir_path( __FILE__ ) ) . 'templates/my-import-users-template.php';
// return $my_custom_template_path;
// For this example, we'll just return the original template, assuming the user
// might have other methods to modify its behavior or content.
return $template;
}
// Always return the original template if it's not the one we're targeting.
return $template;
},
10, // Priority: The default priority is 10.
1 // Accepted Args: The filter accepts 1 argument ($template).
);
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/import-learndash-users-from-csv.php:160
public function __construct() {
if ( ! is_admin() ) {
return;
}
self::$is_module_menu = ( ! empty( filter_input( INPUT_GET, 'page' ) ) && filter_input( INPUT_GET, 'page' ) == self::$module_key ) ? true : false;
self::$template = self::get_template( 'admin-import-user/admin-import-users.php', dirname( dirname( __FILE__ ) ) . '/src' );
self::$template = apply_filters( 'uo_admin_import_users_template', self::$template );
self::$email_template = self::get_template( 'import-user-email.php', dirname( dirname( __FILE__ ) ) . '/src' );
self::$email_template = apply_filters( 'uo_import_user_email_template', self::$email_template );
add_action( 'init', array( __CLASS__, 'init' ) );
add_action( 'plugins_loaded', array( __CLASS__, 'run_backend_hooks' ) );
// Ajax Requests
add_action(
'wp_ajax_Uncanny Toolkit Pro - Import Users : File Upload',
array(
__CLASS__,
'ajax_file_upload',
)
);
add_action(
'wp_ajax_Uncanny Toolkit Pro - Import Users : Options Form',
array(
__CLASS__,
'ajax_option_checked',
)
);
add_action( 'wp_ajax_Uncanny Toolkit Pro - Import Users : Test Email', array(
__CLASS__,
'ajax_test_email',
) );
add_action( 'wp_ajax_Uncanny Toolkit Pro - Import Users : Save Email', array(
__CLASS__,
'ajax_save_email',
) );
add_action(
'wp_ajax_Uncanny Toolkit Pro - Import Users : Perform Import',
array(
__CLASS__,
'ajax_perform_import',
)
);
}