Set minimum password length for profile editor

Simple snippet for Easy Digital Downloads. Adding this snippet to the functions.php of your WordPress theme will let you set a minimum password length within the profile editor.

function pd_edd_pre_update_user_profile( $user_id, $userdata ) {
	// How many characters should the password be?
	$length = 8;
	$password = isset( $_POST['edd_new_user_pass1'] ) ? $_POST['edd_new_user_pass1'] : '';
	if ( ! empty( $password ) && ( strlen( $password ) < $length ) ) {
		edd_set_error( 'password_too_short', sprintf( 'Your password must contain at least %s characters.', $length ) );
add_action( 'edd_pre_update_user_profile', 'pd_edd_pre_update_user_profile', 10, 2 );

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!