-
-
Save mmarj/2d9a87d44c5acb6722e4a5fb7d599a9c to your computer and use it in GitHub Desktop.
Redirects subscribers back to the home page if they attempt to access the 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
<?php | |
/** | |
* Redirects subscribers back to the home page if they attempt to access the dashboard. | |
*/ | |
function prefix_redirect_admin() { | |
if ( ! current_user_can( 'edit_posts' ) && ! defined( 'DOING_AJAX' ) ) { | |
wp_safe_redirect( home_url() ); | |
exit; | |
} | |
} | |
add_action( 'admin_init', 'prefix_redirect_admin' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment