Created
November 27, 2017 14:23
-
-
Save asharirfan/5e9d74869fae725c7ef0c86ad755cc91 to your computer and use it in GitHub Desktop.
WPC β Print current user roles in WP admin dashboard with Custom Setting π―
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 | |
/** | |
* Tell My Role. | |
* | |
* Get the roles of current user and display it. | |
* | |
* @since 1.0.0 | |
*/ | |
function tmr_display_current_user_role() { | |
// Get current user. | |
$current_user = wp_get_current_user(); | |
// Get the user roles. | |
$current_user_roles = $current_user->roles; | |
// Convert user roles array into a string. | |
$current_user_roles = implode( ', ', $current_user_roles ); | |
// Get `tmr_setting` setting. Default value is false. | |
$tmr_setting = get_option( 'tmr_setting', false ); | |
// Display user roles. | |
echo '<p class="tmr_user_roles tmr_user_roles__head">' . esc_html( $tmr_setting . ' ' . $current_user_roles ) . '</p>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment