Filter uncanny-toolkit-pro

uo_import_user_email_template

Filters the email template used for user import notifications before sending.

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

Description

This filter allows developers to modify the email template used for user import notifications. You can alter the `$email_template` to customize the content or structure of these emails, ensuring specific information is conveyed to users upon import. This hook is intended for internal use by the plugin.


Usage

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

Parameters

$email_template (mixed)
This parameter contains the email template content that will be used for importing LearnDash users from a CSV file.

Return Value

The filtered value.


Examples

add_filter( 'uo_import_user_email_template', 'my_custom_user_import_email_template', 10, 1 );

/**
 * Customize the email template used for importing users.
 *
 * This function allows you to modify the HTML content of the email sent to users
 * after they have been successfully imported into WordPress.
 *
 * @param string $email_template The default email template HTML.
 * @return string The modified email template HTML.
 */
function my_custom_user_import_email_template( $email_template ) {
	// For demonstration purposes, let's add a custom message to the email.
	// In a real scenario, you might want to dynamically generate content
	// based on imported user data or plugin settings.

	$custom_message = '<p>Welcome to our platform! You have been successfully registered.</p>';

	// Find a suitable place to insert the custom message.
	// This assumes the default template has a body where we can append.
	// You'd need to inspect the actual $email_template to be more precise.
	$search_string = '</body>';
	$replace_string = $custom_message . '</body>';

	$modified_template = str_replace( $search_string, $replace_string, $email_template );

	// If the search string wasn't found (unlikely but possible), return the original template.
	if ( $modified_template === $email_template ) {
		return $email_template;
	}

	return $modified_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:162

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',
			)
		);
	}


Scroll to Top