Hide WordPress login page without plugin |

Congrats, You are Subscribed to Receive Updates.

Hide WordPress login page without plugin

Hide WordPress login page without plugin. This is a simple way to prevent User access your WordPress default login page.  Some times you need to prevent your site users to access your admin section.


The action Hook “ login_init ” helps you to run a snippet before loading login page.  So the follwoing code help you to redirect the login page to 404 page.  I mean page not found error page.

function kv_no_loginpage_access() { 
	global $wp_query;
	status_header( 404 );
	get_template_part( 404 ); 
add_action( 'login_init' , 'kv_no_loginpage_access' ); 
add_action( 'admin_init' , 'kv_no_loginpage_access' );

So making your WordPress hard to prevent user access. Instead of the 404 page. you can redirect them to  a custom login page to get some front end your rights. May be you have premium things.  which you want to show it to the premium subscribers.

function kv_no_loginpage_access() { 
	get_template_part( 'custom-login-page' ); 

That’s it. now you can prevent your visitor to access your site login page.




About Varadharaj V

The founder of Kvcodes, Varadharaj V is an ERP Analyst and a Web developer specializing in WordPress(WP), WP Theme development, WP Plugin development, Frontaccounting(FA), Sales, Purchases, Inventory, Ledgers, Payroll & HRM, CRM, FA Core Customization, PHP and Data Analyst. Database Management Advance Level

Comment Below

Your email address will not be published. Required fields are marked *


Current ye@r *