Filter uncanny-learndash-toolkit

uo-front-login-reset-template

Filters the login reset template that is loaded to allow customization before it's displayed.

add_filter( 'uo-front-login-reset-template', $callback, 10, 2 );

Description

Allows developers to filter the template loaded for the default login and reset password UI. This hook is called before the template is included, enabling customization of the displayed template based on specific conditions or custom logic, particularly when handling password reset requests.


Usage

add_filter( 'uo-front-login-reset-template', 'your_function_name', 10, 2 );

Parameters

$template_to_load (mixed)
This parameter holds the template file path that the plugin will load for displaying the password reset form.
$template_to_load (mixed)
This parameter is the path to the template file that will be loaded to display the login or reset password form.

Return Value

The filtered value.


Examples

<?php
/**
 * Example of how to use the 'uo-front-login-reset-template' filter.
 * This filter allows you to change the template file loaded for the
 * password reset form on the front-end.
 */
add_filter( 'uo-front-login-reset-template', 'my_custom_password_reset_template', 10, 2 );

/**
 * Custom function to filter the password reset template.
 *
 * @param string $template_to_load The default template file path.
 * @param string $original_template_slug The original slug used to determine the template.
 * @return string The path to the custom template file to load.
 */
function my_custom_password_reset_template( $template_to_load, $original_template_slug ) {
	// Example: If the original template slug indicates a default login page
	// and we want to use a completely custom template for password reset.
	if ( 'frontend-login' === $original_template_slug ) {
		// Assuming you have a custom template file named 'my-custom-reset-password.php'
		// located within your theme's directory.
		// You would typically enqueue scripts and styles for this custom template separately.
		return get_stylesheet_directory() . '/templates/my-custom-reset-password.php';
	}

	// If not the specific case we want to override, return the original template.
	return $template_to_load;
}

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/login-page-ui-default.php:86
src/templates/login-page-ui-default.php:138
src/templates/login-page-ui-default.php:151

//When user clicks reset password link in email!
			if ( isset( $_GET['key'] ) && isset( $_GET['login'] ) ) {
				$rp_key    = $_GET['key'];
				$rp_login  = $_GET['login'];
				$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
				$value     = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) );
				//setcookie( $rp_cookie, $value, 0, '/' . get_post_field( 'post_name', $login_page ), COOKIE_DOMAIN, is_ssl(), true );
				include Config::get_template( apply_filters( 'uo-front-login-reset-template', 'frontend-login/' . $template_to_load . '-reset-pwd.php', $template_to_load ) );
			} else {
				?>

				<div class="uo-default-message-block">
					<div class="uo-default-message-text">
						<?php echo $innerText['Password-Reset-Link-Failed']; ?>
					</div>


Scroll to Top