Created
July 15, 2015 08:08
-
-
Save maxkostinevich/63934b0e8a498a1b24a1 to your computer and use it in GitHub Desktop.
Restrict access to WP-Admin dashboard in WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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