Home / Admin / Block WP-Admin Area from Non-Administrators
Duplicate Snippet

Embed Snippet on Your Site

Block WP-Admin Area from Non-Administrators

Prevent users who are not administrators from accessing the wp-admin area.

Code Preview
php
<?php
add_action( 'admin_init', function() {
	if ( ! current_user_can( 'administrator' ) ) {
       wp_redirect( home_url() );
       exit;
	}
} );

Comments

Add a Comment