Skip to content

Instantly share code, notes, and snippets.

@maxkostinevich
Created July 15, 2015 08:08
Show Gist options
  • Save maxkostinevich/63934b0e8a498a1b24a1 to your computer and use it in GitHub Desktop.
Save maxkostinevich/63934b0e8a498a1b24a1 to your computer and use it in GitHub Desktop.
Restrict access to WP-Admin dashboard in WordPress
<?php
// RESTRICT ACCESS TO WP-ADMIN DASHBOARD
function restrict_admin_access(){
if( !current_user_can( 'edit_posts' ) ) {
wp_redirect( home_url() );
die();
}
}
add_action( 'admin_init', restrict_admin_access, 1 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment