Forked from travislima/replace_spaces_with_underscores.php
Last active
April 8, 2021 20:30
-
-
Save pbrocks/21a1934b717e88bdf28cd04378b2d4c7 to your computer and use it in GitHub Desktop.
Convert capital letters to lowercase and replace spaces with underscores "_" in order to standardize usernames.
This file contains 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 // Do not copy this tag. | |
/** | |
* Convert capital letters to lowercase and replace all spaces with an underscore when | |
* new users register for Paid Memberships Pro. | |
* Add this code to your PMPro Customizations Plugin - | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_custom_user_registration_changes( $userdata ) { | |
$userdata['user_login'] = str_replace(' ', '_', strtolower( $userdata['user_login'] ) ); | |
return $userdata; | |
} | |
add_filter( 'pmpro_checkout_new_user_array', 'my_custom_user_registration_changes', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This recipe is included in the blog post "Reformat usernames to use allowed characters after checkout." at Paid Memberships Pro here: https://www.paidmembershipspro.com/reformat-usernames-to-use-allowed-characters-after-checkout/