PHP 7 Script to Remove Remember me Option From WordPress Login Form in Browser Full Project For Beginners

  • Post author:
  • Post category:PHP
  • Post comments:0 Comments

 

 

Remember Me Not

Completely remove the “Remember Me” option from the WordPress Login form.

Description

The “Remember Me” option is useful to keep you logged into your WordPress account on your personal computer.

However if it is used on a public or non-secure computer then, as it will leave an account logged in on the computer for 2 weeks, it can expose your site to unauthorised users.

The Remember Me Not plugin completely disables this functionality by resetting any attempts to set the “Remember Me” option, and completely removing the checkbox from the Login form (rather than just hiding it).

Installation

  1. Download and unzip the remembermenot plugin file and upload the directory to your wp-content/plugins directory or use the built in WordPress installer.
  2. Go to the Plugins admin page and Activate the plugin, if you want the plugin activated network wide then network activate the plugin in the Network admin plugins page.
  3. That’s it – Remember Me is gone

 

 

 

 

<?php
/*
Plugin Name: Remember Me Not
Version: 1.1
Plugin URI: https://github.com/shrkey/remembermenot
Description: Completely removes the Remember Me functionality from WordPress
Author: Shrkey
Author URI: http://shrkey.com
Text_domain: shrkey
Copyright 2013 (email: team@shrkey.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

$root_dir = __DIR__;

// Include the plugin functions
require_once( $root_dir . '/includes/functions.php' );

if ( remembermenot_on_login_page() ) {
	require_once( $root_dir . '/classes/public.remembermenot.php' );
}

 

 

<?php

// We initially need to make sure that this function exists, and if not then include the file that has it.
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
	require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
}

if ( ! function_exists( 'remembermenot_on_login_page' ) ) {
	/**
	 * Check whether we are on the login page.
	 *
	 * @return bool
	 */
	function remembermenot_on_login_page() {
		return isset( $GLOBALS['pagenow'] ) && in_array( $GLOBALS['pagenow'], array( 'wp-login.php' ) );
	}
}

 

 

<?php

if ( ! class_exists( 'remembermenotpublic' ) ):
	/**
	 * Class remembermenotpublic
	 */
	class remembermenotpublic {
		/**
		 * remembermenotpublic constructor.
		 */
		public function __construct() {
			// Reset any attempt to set the remember option
			add_action( 'login_head', array( $this, 'reset_remember_option' ), 99 );
			// Add the hook into the login_form
			add_action( 'login_form', array( $this, 'start_login_form_cache' ), 99 );
		}

		/**
		 * Reset remember option.
		 */
		public function reset_remember_option() {
			unset( $_POST['rememberme'] );
		}

		/**
		 * Start login form cache.
		 */
		public function start_login_form_cache() {
			ob_start( array( $this, 'process_login_form_cache' ) );
		}

		/**
		 * Process login form cache.
		 *
		 * @param string $content
		 *
		 * @return string
		 */
		public function process_login_form_cache( $content ) {
			return preg_replace( '/<p class="forgetmenot">(.*)<\/p>/', '', $content );
		}
	}
endif;

new remembermenotpublic;

Leave a Reply