Created
September 25, 2015 13:36
-
-
Save mauriciogofas/8c04b73197f2cec49536 to your computer and use it in GitHub Desktop.
Prevents subscribers access to wp-admin and redirects to specific page of the front end
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 | |
| /* | |
| * Impede o acesso de assinantes ao wp-admin e os redireciona para página específica do front end | |
| * Prevents subscribers access to wp-admin and redirects to specific page of the front end | |
| */ | |
| function gfs_restrict_admin_with_redirect() { | |
| if ( ! current_user_can( 'edit_posts' /* edit_posts = minimum capacity required to access the dashboard */ ) && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) { | |
| wp_redirect( site_url() . '/?p=322' ); // 322 = Page ID to redirect | |
| exit; | |
| } | |
| } | |
| add_action( 'admin_init', 'gfs_restrict_admin_with_redirect', 1 ); | |
| // End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment