Created
October 10, 2014 10:11
-
-
Save thierrypigot/1559f6a784aad064ea98 to your computer and use it in GitHub Desktop.
Redirect non admin to front
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 non admin to front | |
**/ | |
add_action( 'admin_init', 'tp_demo_redirect_non_admin_users' ); | |
function tp_demo_redirect_non_admin_users() | |
{ | |
if ( ! current_user_can( 'manage_options' ) && '/wp-admin/admin-ajax.php' != $_SERVER['PHP_SELF'] ) { | |
wp_safe_redirect( home_url() ); | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A utiliser dans un mu plugin + le plugin "restricted site access", pour offrir un site bloqué aux moteurs de recherche mais disponible pour une démo client sans accès au Backoffice.
https://wordpress.org/plugins/restricted-site-access/