Filter uncanny-learndash-groups

ulgm_password_length

Filters the minimum required password length for user accounts before it is enforced.

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

Description

Fires within `ulgm_password_length` to modify the generated password's length. Developers can return a new integer to set a custom password length. Defaults to 18.


Usage

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

Parameters

$length (mixed)
This parameter is the desired length for the generated password.

Return Value

The filtered value.


Examples

<?php
/**
 * Filter to adjust the default password length for ULGM generated passwords.
 *
 * This example increases the default password length to 24 characters
 * to enhance security.
 *
 * @param int $length The current password length.
 * @return int The modified password length.
 */
add_filter( 'ulgm_password_length', function( $length ) {
    // Increase the default password length to 24 characters for better security.
    $new_length = 24;
    return $new_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/classes/helpers/shared-functions.php:960

public static function wp_generate_password( $length = 18, $special_chars = true, $extra_special_chars = false ) {
		$length              = apply_filters( 'ulgm_password_length', $length );
		$special_chars       = apply_filters( 'ulgm_password_special_chars', $special_chars );
		$extra_special_chars = apply_filters( 'ulgm_password_extra_special_chars', $extra_special_chars );

		return wp_generate_password( $length, $special_chars, $extra_special_chars );
	}


Scroll to Top