Skip to content

Instantly share code, notes, and snippets.

@paulgoodchild
Created September 18, 2019 09:45
Show Gist options
  • Save paulgoodchild/29c4cc2e13179f8de2f5669486487cfa to your computer and use it in GitHub Desktop.
Save paulgoodchild/29c4cc2e13179f8de2f5669486487cfa to your computer and use it in GitHub Desktop.
Restrict WP Admin Dashboard Access From Subscribers
<?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