Created
June 4, 2015 09:30
-
-
Save yratof/c7fef3c1487341566674 to your computer and use it in GitHub Desktop.
Woocommerce - Non-admins shouldn't be able to see wordpress
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 | |
| // Non-admins can't login, they're redirected to the video/videos page, | |
| // which stops them from messing with the website. | |
| $goodbye = site_url(); | |
| function force_login_redirect( $redirect_to, $request, $user ) { | |
| return ( is_array( $user->roles ) && in_array( 'administrator', $user->roles ) ) ? admin_url() : $goodbye; | |
| } | |
| add_filter( 'login_redirect', 'force_login_redirect', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment