WordPress filter hook · part of WordPress core
pre_user_login
A WordPress core filter that 14 plugins also fire themselves, running on 198K+ sites between them.
“Filters the username before being validated.”
How to use pre_user_login
It's a filter: your callback receives the value, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'pre_user_login', function( $user_login ) {
// Change $user_login here.
return $user_login;
}, 10, 1 );Argument names come from LTI Tool's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
This hook is fired by WordPress core too. Official reference on developer.wordpress.org →
14 plugins that fire pre_user_login
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
Advanced Custom Fields: Extended100,000+ installs
apply_filters( 'pre_user_login', $action['save']['user_login'] )includes/modules/form/module-form-action-user.php:223 -
BuddyPress90,000+ installs
apply_filters( 'pre_user_login', $user_name )bp-members/bp-members-functions.php:1705 -
FeedWordPress8,000+ installs
apply_filters( 'pre_user_login', sanitize_user( $newuser_name ) )admin-ui.php:431 -
Court Reservation80+ installs
apply_filters( 'pre_user_login', sanitize_user( wp_unslash( $_REQUEST['user_login'] ), true ) )admin/partials/courtres-user.php:190 -
Import Members from CSV for Paid Memberships Pro80+ installs
apply_filters( 'pre_user_login', $sanitized_user_login )src/modules/Users/class-import-user.php:368 -
LTI Tool50+ installs
apply_filters( 'pre_user_login', $user_login )includes/SyncEnrolments.php:84 -
Create User With Password Multisite40+ installs
apply_filters( 'pre_user_login', sanitize_user(wp_unslash($_REQUEST['user_login']), true) )php/cuwp.php:116 -
PHPBB Single Sign On10+ installs
apply_filters( 'pre_user_login', $user_login )module.wp.php:15 -
SPR Posts Import10+ installs
apply_filters( 'pre_user_login', $auth->creator->__toString() )app/models/main_model.php:84 -
KickPress10+ installs
apply_filters( 'pre_user_login', sanitize_user( stripslashes( $user_login ), true ) )kickpress-api.php:1989 -
PopForms Lite10+ installs
apply_filters( 'pre_user_login', sanitize_user( $user_name ) )inc/pop-functions.php:121 -
Add user 2 in 1Fewer than 10 installs
apply_filters( 'pre_user_login', sanitize_user( wp_unslash( $_REQUEST['user_login'] ), true ) )add-form.php:156 -
Lil’Omi AvatarsFewer than 10 installs
apply_filters( 'pre_user_login', $trim_user_login )_process_user.php:22 -
vXor ConvertorFewer than 10 installs
apply_filters( 'pre_user_login', $user_login )lib/convert.func.php:412
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.