#Overview
This filter runs when a new user is being imported, either via the import tool or a webhook. It allows you to modify a user’s meta data after it’s been loaded from the CRM, but before the new user has been inserted.
To use the code examples below, add them to your active theme’s functions.php file.
#Parameters
$user_meta
: Array of user meta data, in the formatarray('meta_field' => 'value')
.$contact_id
: CRM contact ID of the user being imported
#Examples
#Set imported users to have usernames generated from their first and last names, instead of email address
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' );
#Set imported users to have usernames generated from their first name and a random number, instead of email address
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' );
Was this helpful?
Let us know if you liked the post. That’s the only way we can improve.