Back to Community

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:

  1. Access Your Code: You will need to add this code to your theme's functions.php file. 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.
  2. 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.
  3. 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=lostpassword URL with your page's direct link.
  4. 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