The login_form WordPress PHP action fires immediately after the ‘Password’ field in the login form, allowing you to add custom content or modify the form.
Usage
add_action('login_form', 'your_custom_function'); function your_custom_function() { // your custom code here }
Parameters
- None
More information
See WordPress Developer Resources: login_form
Examples
Add a custom message below the password field
Display a custom message to users below the password field in the login form.
add_action('login_form', 'add_custom_message'); function add_custom_message() { echo '<p class="message">**Remember to keep your password secure!**</p>'; }
Add a “Forgot Password” link
Insert a “Forgot Password” link below the password field in the login form.
add_action('login_form', 'add_forgot_password_link'); function add_forgot_password_link() { echo '<p><a href="' . wp_lostpassword_url() . '">**Forgot your password?**</a></p>'; }
Display a reCAPTCHA
Integrate a Google reCAPTCHA in the login form to protect against spam and bots.
add_action('login_form', 'display_recaptcha'); function display_recaptcha() { echo '<div class="g-recaptcha" data-sitekey="**your-recaptcha-site-key**"></div>'; }
Add a privacy policy checkbox
Add a privacy policy agreement checkbox to the login form.
add_action('login_form', 'add_privacy_policy_checkbox'); function add_privacy_policy_checkbox() { echo '<p><label><input type="checkbox" required> I agree to the **Privacy Policy**</label></p>'; }
Insert social login buttons
Add social login buttons (e.g., Facebook, Google) below the password field.
add_action('login_form', 'insert_social_login_buttons'); function insert_social_login_buttons() { echo '<div class="social-login-buttons">'; echo '<a href="#" class="facebook-login">**Login with Facebook**</a>'; echo '<a href="#" class="google-login">**Login with Google**</a>'; echo '</div>'; }