Skip to content

Instantly share code, notes, and snippets.

@femiyb
Last active January 13, 2020 08:46
Show Gist options
  • Save femiyb/36ac74fccd35acf1fba2b675bc3c7e60 to your computer and use it in GitHub Desktop.
Save femiyb/36ac74fccd35acf1fba2b675bc3c7e60 to your computer and use it in GitHub Desktop.
Set minimum length for username checkouts for Paid Memberships Pro
<?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