To validate the login details before user logins, you can use the below function:
(p.s. At first, you may have inserted some extra fields using ‘login_form’ action hook.)
function wpdocs_ref_access() {
global $error;
if ( empty( $_POST['custom_field_name'] ) ) {
$error = 'Restricted area, please login to continue.';
}
}
add_action( 'login_head', 'wpdocs_ref_access' );
If you are still using the filter login_head to enqueue style for change logo URL, I recommend to use login_enqueue_scripts instead.
It’s OK to keep using this filter hook, but if you read the doc block on wp-login.php file above the filter login_enqueue_scripts. You will see that, it said Enqueues scripts and styles for the login page which is best fit for its purpose. That’s all.
You must log in before being able to contribute a note or feedback.
More Information
login_head handles authentication, registering, resetting passwords, forgot password,
and other user handling.
The login_head filter can be used to filter the logo image on the WordPress login page. By default this logo is of WordPress.
Note: this is not the only possible use of this filter. It can be used to add anything to the section on the login page.
Basic Examples
Where “wpdocs_custom_function_name” is the function to be called when the content is being retrieved.
In the below example the default logo is changed to custom logo, using CSS.
To validate the login details before user logins, you can use the below function:
(p.s. At first, you may have inserted some extra fields using ‘login_form’ action hook.)
If you are still using the filter
login_headto enqueue style for change logo URL, I recommend to uselogin_enqueue_scriptsinstead.It’s OK to keep using this filter hook, but if you read the doc block on wp-login.php file above the filter
login_enqueue_scripts. You will see that, it said Enqueues scripts and styles for the login page which is best fit for its purpose. That’s all.