1

How to change username before submitting in login form ?

I have used mobile number as username when a user registers in site. also I have removed 0 from the beginning of the mobile number. Now in login form I need to remove 0 from the beginning of the mobile number, if user enter the mobile number with 0. Is there a function to use as an action in functions.php

1 Answer 1

2

You can use wp_authenticate filter for that... This filter is fired before the user is authenticated. Params are passed by reference, so you can modify them.

// user name is passed in by reference function wp_authenticate_by_email( &$username ) { // make sure that the condition below works for you if ( is_numeric( $username ) && '0' == substr( $username, 0, 1 ) ) { $username = substr( $username, 1 ); } } add_action( 'wp_authenticate', 'wp_remove_leading_zero_from_phone_number' ); 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.