Last active
August 29, 2015 14:14
-
-
Save mihdan/5a79359a77da1a0cb746 to your computer and use it in GitHub Desktop.
Закрыть доступ в админку для всех кроме админа
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 | |
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