Last active
May 14, 2022 15:54
-
-
Save devinsays/e7a4d3d889069e5c40f7 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