Skip to content

Instantly share code, notes, and snippets.

@khripunovpp
Created February 27, 2017 17:23
Show Gist options
  • Save khripunovpp/8ed873d5b7d3931dd9282cf02fe93cda to your computer and use it in GitHub Desktop.
Save khripunovpp/8ed873d5b7d3931dd9282cf02fe93cda to your computer and use it in GitHub Desktop.
Ограничение доступа к панели WordPress с помощью кода для всех кроме администратора
functions.php
add_action( 'init', 'blockusers_init' );
function blockusers_init() {
if ( is_admin() && ! current_user_can( 'administrator' ) &&
! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
wp_redirect( home_url() );
exit;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment