How to Make the “Remember Me” Checkbox Checked by Default on WordPress Login

Ensuring that the “Remember Me” checkbox is checked by default on your WordPress login page can enhance user convenience, especially for frequent visitors. This guide will walk you through the process of achieving this by adding a small piece of code to your theme’s functions.php file. By following these steps, you can streamline the login process for your users, making it easier for them to stay logged in.

How to Make the “Remember Me” Checkbox Checked by Default on WordPress Login

Step-by-Step Guide

  1. Access Your Theme’s functions.php File The functions.php file is where you can add custom code to modify the behavior of your WordPress site. You can access this file in a couple of ways:
    • Via the WordPress Dashboard:
      • Navigate to Appearance > Theme File Editor.
      • In the right-hand sidebar, find and click on the functions.php file. This will open the file in the editor.
    • Via FTP or Hosting Control Panel:
      • Use an FTP client or your hosting control panel’s file manager to navigate to your theme’s directory, typically found at wp-content/themes/your-theme-name/.
      • Locate and open the functions.php file.
  2. Add the Custom Code Once you have the functions.php file open, you need to add a small piece of code that will automatically check the “Remember Me” checkbox when the login page loads. Here is the code you need to add: function set_remember_me_checked() { echo '<script>document.getElementById("rememberme").checked = true;</script>'; } add_action('login_footer', 'set_remember_me_checked'); This code snippet does the following:
    • Function Definition: The set_remember_me_checked function outputs a small JavaScript snippet.
    • JavaScript Execution: The JavaScript code sets the “checked” property of the “Remember Me” checkbox (rememberme) to true.
    • Hooking into login_footer: The add_action function hooks our custom function into the login_footer action, ensuring that our JavaScript runs when the login page footer is rendered.
  3. Save the Changes After adding the code, save the changes to the functions.php file. If you are using the Theme File Editor, simply click the “Update File” button. If you are using an FTP client or file manager, make sure to upload the modified file back to your server.

Testing the Changes

To ensure that the changes have been applied correctly, log out of your WordPress site and navigate to the login page. You should see that the “Remember Me” checkbox is now checked by default. If it is not, double-check the code you added to ensure there are no typos or errors.

Additional Considerations

  • Child Theme: If you are using a parent theme, consider adding this code to a child theme’s functions.php file. This way, your changes won’t be overwritten when the parent theme is updated.
  • Plugin Alternative: If you prefer not to modify your theme’s files, you can look for a plugin that offers similar functionality. There are several plugins available in the WordPress repository that can help you customize the login page.

By following these steps, you can make the “Remember Me” checkbox checked by default, providing a more seamless login experience for your users. This small tweak can significantly enhance user convenience, especially for those who frequently log in to your site.

Users Discussion Section

Scroll to Top