How to Add a Forgot Password Link to Your Members Plugin Login Form
Content
Many users of the 'Members – Membership & User Role Editor Plugin' want to provide a way for their members to reset forgotten passwords directly from the front-end login form. This is a common request, as the plugin's primary [members_login_form] shortcode does not include this functionality by default.
This guide will explain why the link isn't there and provide the most common solution for adding it yourself.
Why Isn't There a Forgot Password Link?
The 'Members – Membership & User Role Editor Plugin' is primarily focused on managing user roles and capabilities. Its built-in login form shortcode is designed as a basic utility for logging in, and it does not include advanced features like a password reset link. This keeps the plugin lightweight for its core purpose but means some common membership site features require additional setup.
Solution: Add a Custom Link with Code
The most effective way to add a "Lost Password" link is by using a small snippet of custom PHP code. This code hooks into the login form and adds the link below the login fields.
Step-by-Step Instructions:
- Access Your Code: You will need to add this code to your theme's
functions.phpfile. It is highly recommended to use a child theme to prevent your changes from being overwritten by theme updates. Alternatively, you can use a plugin like "Code Snippets" to manage custom code safely. - Add the Code: Copy and paste the following code snippet:
add_action( 'login_form_middle', 'add_lost_password_link' );
function add_lost_password_link() {
return '<a href="/wp-login.php?action=lostpassword">Forgot Your Password?</a>';
}
This code creates a simple text link that points to the default WordPress password reset page. - Customize the Link (Optional): You can modify the text ('Forgot Your Password?') and the URL within the code to match your site's structure or styling. For example, if you have a custom password reset page, you can replace the
/wp-login.php?action=lostpasswordURL with your page's direct link. - Save and Test: After adding the code, save your file and clear your site's cache if you use a caching plugin. Then, visit the page with your
[members_login_form]shortcode to confirm the link now appears and functions correctly.
Important Considerations
- Styling: The link will inherit basic styles from your theme. You may need to add custom CSS via Appearance > Customize > Additional CSS to make it stand out or match your site's design.
- Plugin Conflicts: The password reset process itself is handled by WordPress or other plugins (like WooCommerce). If users are experiencing errors when trying to reset their password (e.g., "Password reset is not allowed for this user"), the issue is likely unrelated to this code snippet and may be caused by a conflict with another plugin or specific user role settings.
- Translation: If you need to translate the text of the link, you should do so within the code snippet itself, as it is not part of the plugin's standard translatable strings.
By following this guide, you can seamlessly integrate a crucial self-service feature for your users, improving their experience on your site.
Related Support Threads Support
-
icons members pagehttps://wordpress.org/support/topic/icons-members-page/
-
Locked myself out of my sitehttps://wordpress.org/support/topic/locked-myself-out-of-my-site/
-
Cant see fomrs for logins annd othershttps://wordpress.org/support/topic/cant-see-fomrs-for-logins-annd-others/
-
Site Kit googlehttps://wordpress.org/support/topic/site-kit-google/
-
Change messagehttps://wordpress.org/support/topic/change-message-8/
-
Members on phone and tablethttps://wordpress.org/support/topic/members-on-phone-and-tablet/
-
Login form noticehttps://wordpress.org/support/topic/login-form-notice/
-
Password Set/resethttps://wordpress.org/support/topic/password-set-reset/
-
members link on home page yields 404https://wordpress.org/support/topic/members-link-on-home-page-yields-404/
-
Documentation questionhttps://wordpress.org/support/topic/documentation-question-2/
-
Login widget not displaying text on apple deviceshttps://wordpress.org/support/topic/login-widget-not-displaying-text-on-apple-devices/
-
Not accepting passwordhttps://wordpress.org/support/topic/not-accepting-password-3/
-
new user/role, doesn’t let remove items from carthttps://wordpress.org/support/topic/new-user-role-doesnt-let-remove-items-from-cart/
-
Stay Logged in settinghttps://wordpress.org/support/topic/stay-logged-in-setting/
-
Customize the page “Lost your password”https://wordpress.org/support/topic/customize-the-page-lost-your-password/
-
Show/Hide Passwordhttps://wordpress.org/support/topic/show-hide-password-8/
-
Subscriber upload profile pichttps://wordpress.org/support/topic/subscriber-upload-profile-pic/
-
My “Gold Member” role is not allowing users to loginhttps://wordpress.org/support/topic/my-gold-member-role-is-not-allowing-users-to-login/
-
Error 404 Pagehttps://wordpress.org/support/topic/error-404-page-2/
-
Forgot Password link in formhttps://wordpress.org/support/topic/forgot-password-link-in-form/
-
Edit no permissions pagehttps://wordpress.org/support/topic/edit-no-permissions-page/
-
Forgot passwordhttps://wordpress.org/support/topic/forgot-password-27/
-
Where to Approve / Deny user requestshttps://wordpress.org/support/topic/where-to-approve-deny-user-requests/
-
Members forgetting passwordshttps://wordpress.org/support/topic/members-forgetting-passwords/
-
How to Stop Bots from Registering?https://wordpress.org/support/topic/how-to-stop-bots-from-registering/
-
Password reset is not allowed for this userhttps://wordpress.org/support/topic/password-reset-is-not-allowed-for-this-user-16/
-
hCaptcha and Login widget not working togetherhttps://wordpress.org/support/topic/hcaptcha-and-login-widget-not-working-together/
-
Login form is very hard to seehttps://wordpress.org/support/topic/login-form-is-very-hard-to-see/