Created
December 19, 2022 15:10
-
-
Save thierrypigot/6293be08ec48d552fddeb3cbfbf93772 to your computer and use it in GitHub Desktop.
Code qui vérifie le rôle de l'utilisateur lorsqu'il se connecte et qui affiche un message spécifique à l'utilisateur en fonction de son rôle
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 | |
function my_login_message() { | |
global $current_user; | |
$role = $current_user->roles[0]; | |
if ( $role == 'administrator' ) { | |
echo 'Bienvenue administrateur!'; | |
} else { | |
echo 'Bienvenue à vous!'; | |
} | |
} | |
add_action( 'wp_login', 'my_login_message' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment