Created
May 21, 2018 02:54
-
-
Save jerrickhakim/a54a352be47b54a87d9a412de6112fa7 to your computer and use it in GitHub Desktop.
Only admin can access WordPress Dashboard
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
// BLOCK WORDPRESS DASHBOARD | |
function block_dashboard() { | |
$file = basename($_SERVER['PHP_SELF']); | |
if (is_user_logged_in() && is_admin() && !current_user_can('edit_posts') && $file != 'admin-ajax.php'){ | |
wp_redirect( home_url('/account') ); | |
exit(); | |
} | |
} | |
add_action('init', 'block_dashboard'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment