Filter Uncanny Redemption Codes

ulc_registration_min_password_length

Filters the minimum password length allowed for user registrations, allowing you to set custom requirements.

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

Description

Filters the minimum password length required for user registration. Developers can use this hook to enforce custom password complexity rules, increasing security. The default minimum length is 6 characters.


Usage

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

Return Value

The filtered value.


Examples

/**
 * Example: Enforce a minimum password length of 8 characters for user registration.
 *
 * This filter allows developers to override the default minimum password length
 * set by the Uncanny LearnDash Codes plugin for its user registration form.
 *
 * @param int $min_length The current minimum password length.
 * @return int The new minimum password length.
 */
add_filter( 'ulc_registration_min_password_length', function( $min_length ) {
	// Check if the current minimum length is less than our desired length.
	// This ensures we don't accidentally reduce the length if another filter
	// has already increased it beyond our preference.
	$desired_min_length = 8;

	if ( $min_length < $desired_min_length ) {
		return $desired_min_length;
	}

	return $min_length;
}, 10, 1 ); // Priority 10, accepts 1 argument.

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-user-registration-form.php:90
src/templates/frontend-user-registration-form.php:100

</tr>
				<tr>
					<td class="label"><label
							for="password"><?php echo esc_html__( 'Password', 'uncanny-learndash-codes' ); ?></label>
					</td>
					<td class="input"><input name="uncanny-learndash-codes-user_pass" id="password"
											 required="required"
											 minlength="<?php echo sanitize_text_field( apply_filters( 'ulc_registration_min_password_length', 6 ) ); ?>"
											 class="required"
											 type="password"/></td>
				</tr>
				<tr>
					<td class="label"><label
							for="password_again"><?php echo esc_html__( 'Confirm password', 'uncanny-learndash-codes' ); ?></label>
					</td>

Scroll to Top