Skip to content

Instantly share code, notes, and snippets.

@verygoodplugins
Last active July 10, 2018 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save verygoodplugins/49900df29d617018b738d923a2a1301b to your computer and use it in GitHub Desktop.
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
<?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