Created
September 18, 2019 09:45
-
-
Save paulgoodchild/29c4cc2e13179f8de2f5669486487cfa to your computer and use it in GitHub Desktop.
Restrict WP Admin Dashboard Access From Subscribers
This file contains 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 | |
add_action( 'init', function () { | |
if ( is_admin() && !( defined( 'DOING_AJAX' ) && DOING_AJAX ) && !current_user_can( 'edit_posts' ) ) { | |
wp_safe_redirect( home_url() ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment