Skip to content

Instantly share code, notes, and snippets.

@Antoinebr
Created March 30, 2016 17:36
Show Gist options
  • Select an option

  • Save Antoinebr/6dbd17e6bca62f68c3862975f02af129 to your computer and use it in GitHub Desktop.

Select an option

Save Antoinebr/6dbd17e6bca62f68c3862975f02af129 to your computer and use it in GitHub Desktop.
Permet d'interdire des pages de l'admin
<?php
function forbidden_url(){
$forbidenUrls = array(
'theme-editor.php',
'themes.php',
'plugin-editor.php',
'plugin-install.php',
'plugins.php',
'export.php',
'post_type=acf-field-group',
'users.php'
);
foreach ($forbidenUrls as $url) {
if (strpos($_SERVER['REQUEST_URI'], $url) !== FALSE) {
echo "
<div style='text-align:center;'>
<h2 >Pour des raisons de securite cette page n'est pas accesible avec votre compte.
</br/>
(Protection contre le telechargement des fichiers sources)</h2>
<p>L'acces à cette partie sera débloqué après acceptation de la livraison</p>
</div>
";
die();
}
}
}
if( is_user_logged_in()) :
$user_id = get_current_user_id();
if($user_id !== 1) add_action('admin_init','forbidden_url');
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment