Last active
January 13, 2020 08:46
-
-
Save femiyb/36ac74fccd35acf1fba2b675bc3c7e60 to your computer and use it in GitHub Desktop.
Set minimum length for username checkouts for Paid Memberships Pro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function pmpro_check_username_length( $pmpro_continue_registration ) { | |
//only bother if things are okay so far | |
if(!$pmpro_continue_registration) | |
return $pmpro_continue_registration; | |
$username = $_REQUEST['username']; | |
if ( !is_user_logged_in() ) { | |
if ( strlen( $username ) < 5 ) { | |
pmpro_setMessage( esc_html__( 'Your username must be at least 5 characters long.' ), 'pmpro_error' ); | |
return false; | |
} | |
} | |
return $pmpro_continue_registration; | |
} | |
add_filter( 'pmpro_registration_checks', 'pmpro_check_username_length' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment