Created
August 19, 2020 09:36
-
-
Save cladjidane/30a9eb2814fd23d57a8e6d6eadbc9164 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Méthodes pour personnaliser l'admin profil d'un user | |
*/ | |
// Suppression des différentes infos - voir les commentaires par ligne | |
if ( ! function_exists( 'k_remove_personal_options' ) ) { | |
function k_remove_personal_options( $subject ) { | |
$user = wp_get_current_user(); | |
if ( !in_array('editor', $user->roles) ) { | |
$subject = preg_replace('#<h2>'.__("Personal Options").'</h2>#s', '', $subject, 1); // Suppression du titre "Options personnelles" | |
$subject = preg_replace('#<tr class="user-rich-editing-wrap(.*?)</tr>#s', '', $subject, 1); // Suppression du champ "Éditeur visuel" | |
$subject = preg_replace('#<tr class="user-comment-shortcuts-wrap(.*?)</tr>#s', '', $subject, 1); // Suppression du champ "Raccourcis clavier" | |
$subject = preg_replace('#<tr class="show-admin-bar(.*?)</tr>#s', '', $subject, 1); // Suppression du champ "Barre d’outils" | |
$subject = preg_replace('#<h2>'.__("Name").'</h2>#s', '', $subject, 1); // Suppression du titre "Nom" | |
$subject = preg_replace('#<tr class="user-display-name-wrap(.*?)</tr>#s', '', $subject, 1); // Suppression du champ "Nom à afficher publiquement"- | |
$subject = preg_replace('#<h2>'.__("Contact Info").'</h2>#s', '', $subject, 1); // Suppression du titre "Informations de contact" | |
$subject = preg_replace('#<tr class="user-url-wrap(.*?)</tr>#s', '', $subject, 1); // Suppression du champ "Site web" | |
$subject = preg_replace('#<h2>'.__("About Yourself").'</h2>#s', '', $subject, 1); // Suppression du titre "À propos de vous" | |
$subject = preg_replace('#<tr class="user-description-wrap(.*?)</tr>#s', '', $subject, 1); // Suppression du champ "Renseignements biographiques" | |
$subject = preg_replace('#<tr class="user-profile-picture(.*?)</tr>#s', '', $subject, 1); // Suppression du champ "Illustration du profil" | |
$subject = preg_replace('#<tr class="user-language-wrap(.*?)</tr>#s', '', $subject, 1); // Suppression du champ "Langue" | |
} | |
return $subject; | |
} | |
function k_profile_subject_start() { | |
if ( ! current_user_can('manage_options') ) { | |
ob_start( 'k_remove_personal_options' ); | |
} | |
} | |
function k_profile_subject_end() { | |
if ( ! current_user_can('manage_options') ) { | |
ob_end_flush(); | |
} | |
} | |
} | |
add_action( 'admin_head', 'k_profile_subject_start' ); | |
add_action( 'admin_footer', 'k_profile_subject_end' ); | |
// Pour supprimer l'identifiant (qui de toute faàon est non modifiable) il faut gruger un peu en js | |
function remove_personal_options(){ | |
if ( ! current_user_can('manage_options') ) { // 'update_core' est peut-être plus approprié | |
echo '<script type="text/javascript">jQuery(document).ready(function($) { | |
$(\'form#your-profile tr.user-nickname-wrap\').hide(); // Hide the "nickname" field | |
});</script>'; | |
} | |
} | |
add_action('admin_head','remove_personal_options'); | |
// Ici on supprimer le choix des couleurs de l'admin | |
remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.