Last active
July 10, 2018 17:54
-
-
Save verygoodplugins/49900df29d617018b738d923a2a1301b to your computer and use it in GitHub Desktop.
Users imported by webhook will have usernames generated from their first and last names, instead of email address
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 | |
// Use first name and lastname as the username | |
function wpf_use_names_as_logins( $user_meta ) { | |
$user_meta['user_login'] = strtolower( $user_meta['first_name'] . $user_meta['last_name'] ); | |
return $user_meta; | |
} | |
add_filter( 'wpf_import_user', 'wpf_use_names_as_logins' ); | |
// OR | |
// Use a random number after the first name as the username | |
function wpf_use_names_as_logins( $user_meta ) { | |
$user_meta['user_login'] = strtolower( $user_meta['first_name'] ) . rand(10, 1000); | |
return $user_meta; | |
} | |
add_filter( 'wpf_import_user', 'wpf_use_names_as_logins' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment