Last active
November 22, 2016 10:38
-
-
Save X-Raym/97fdc1e705d8aa631cd17943def8b747 to your computer and use it in GitHub Desktop.
Automatically format user last name and first name to regular case at WordPress registration/sign-up.
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 | |
| add_action( 'user_register', 'registration_user_names_case', 10, 1 ); | |
| function registration_user_names_case( $user_id ) { | |
| if ( isset( $_POST['first_name'] ) ) | |
| $first_name_new = mb_convert_case($first_name, MB_CASE_TITLE, "UTF-8"); | |
| update_user_meta($user_id, 'first_name', $first_name_new); | |
| if ( isset( $_POST['last_name'] ) ) | |
| $last_name_new = mb_convert_case($last_name, MB_CASE_TITLE, "UTF-8"); | |
| update_user_meta($user_id, 'last_name', $last_name_new); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment