Skip to content

Instantly share code, notes, and snippets.

@mihdan
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mihdan/5a79359a77da1a0cb746 to your computer and use it in GitHub Desktop.
Save mihdan/5a79359a77da1a0cb746 to your computer and use it in GitHub Desktop.
Закрыть доступ в админку для всех кроме админа
<?php
function ms_users_redirect() {
global $pagenow;
if( defined('DOING_AJAX') && DOING_AJAX ) {
return;
}
$allowed = [
'admin-ajax.php' // например
];
// Если запрс не в разрешенных - редирект на морду
if ( ! in_array( $pagenow, $allowed ) ) {
if ( ! is_super_admin() ) {
wp_redirect( site_url() );
die();
}
}
}
add_action( 'admin_init','ms_users_redirect' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment