Skip to content

Instantly share code, notes, and snippets.

@thierrypigot
Created October 10, 2014 10:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thierrypigot/1559f6a784aad064ea98 to your computer and use it in GitHub Desktop.
Save thierrypigot/1559f6a784aad064ea98 to your computer and use it in GitHub Desktop.
Redirect non admin to front
<?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;
}
}
@thierrypigot
Copy link
Author

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment