How To Hide WordPress Admin URL - Kvcodes
X

Congrats, You are Subscribed to Receive Updates.

How To Hide WordPress Admin URL


How To Hide WordPress Admin URL, Hiding admin url becomes more important now a days to prevent the Brute-force attack. Let’s discuss the security measures, which helps you to avoid accessing admin page if the user is not logged in.  The following code snippet helps you to prevent brute-force tries.

function kv_prevent_admin_url() {
	if( !is_user_logged_in() ) ) {
		wp_die('404 - File not found!', 'File Not Found', array('response' => 404));
    	}
}
add_action( 'admin_init', 'kv_prevent_admin_url', 1 );

The above code, makes your site to verify the current user and if no user is logged in and trying to access admin interface, it will redirect them to 404 page- file not found page. But we need to prevent the login page redirect before a user is logged in. So, we need to add one more security measure to prevent the login access.

add_action( 'site_url', 'kv_prevent_admin_url', 1 );

add_action( 'login_url', 'kv_prevent_admin_url', 1 );

If you have any doubt or clarification comment below.

commenter

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, OpenCart Theme Development, PHP, HTML, CSS, jQuery, Bootstrap development and content SEO.

Comment Below

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

*

Current ye@r *

Menu

Sidebar

Subscribe E-mail Updates

Congrats, You are Subscribed to Receive Updates.

Advertisement

Category Posts