<?php
/**
Plugin Name: Password Protect with username
Plugin URI: https://google.com
Description: Password protect with username.
Version: 4.0
Author: kinjal dalwadi
Author URI: https://automattic.com/wordpress-plugins/
License: GPLv2 or later
Text Domain: passowrdprotects
*/
function VSPFW_un_is_login_page() {
return in_array($GLOBALS['pagenow'], array('wp-login.php'));
}
function my_un_CheckPassword() {
if (!is_admin() && !VSPFW_un_is_login_page() && !current_user_can('manage_options')) {
if (!is_user_logged_in()) {
require('login_view.php');
exit();
//return true;
}
}
}
add_action('init', 'my_un_CheckPassword',50);
function restrict_admin(){
//if not administrator, kill WordPress execution and provide a message
if ( ! current_user_can( 'delete_others_posts' ) ) {
wp_die( __('You are not allowed to access this part of the site') );
}
}
add_action( 'admin_init', 'restrict_admin', 1 );
add_filter('show_admin_bar', '__return_false');
?>