I want to call a custom function before login using the entered login & password and if that function returns true
than user should proceed to login.
I have tried add_action('wp_login', 'do_anything');
to do this but it called my custom function after login.
Is there any way to do call custom function before login?
You're looking for the wp_authenticate action hook.
This action is located inside of wp_signon
. In contrast to the wp_login
action, it is executed before the WordPress authentication process.
EDIT: You didn't include much info in your post, but the wp_authenticate_user filter may also be useful.
The wp_authenticate_user
filter hook is used to perform additional validation/authentication any time a user logs in to WordPress.