Created
July 12, 2015 20:17
-
-
Save webmasterninjay/75b9a4fa6fed4c605847 to your computer and use it in GitHub Desktop.
WordPress: Redirect non-admin user to My Account page
This file contains hidden or 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 | |
/** | |
* Redirect back to homepage and not allow access to | |
* WP admin for Subscribers. | |
*/ | |
function jay_redirect_admin(){ | |
if ( ! current_user_can( 'edit_posts' ) ){ | |
wp_redirect( site_url('/my-account') ); | |
exit; | |
} | |
} | |
add_action( 'admin_init', 'jay_redirect_admin' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment