-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtell-my-role.php
More file actions
66 lines (58 loc) · 1.39 KB
/
tell-my-role.php
File metadata and controls
66 lines (58 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* Plugin Name: Tell My Role
* Plugin URI: https://WPCouple.com
* Description: A plugin to display user roles in WordPress dashboard.
* Version: 1.0.0
* Author: WPCouple
* Author URI: https://WPCouple.com
* Contributors: WPCouple, mrasharirfan
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: tell-my-role
*
* @package tell-my-role
*/
/**
* 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 );
// Display user roles.
echo '<p class="tmr_user_roles tmr_user_roles__head">' . esc_html( $current_user_roles ) . '</p>';
}
// Hook it!
add_action( 'admin_notices', 'tmr_display_current_user_role' );
/**
* Style the Display.
*
* This method styles the user roles.
*
* @since 1.0.0
*/
function tmr_style_display() {
?>
<style>
.tmr_user_roles {
display: inline-block;
text-transform: uppercase;
}
.tmr_user_roles__head {
background: #0085ba;
color: #ffffff;
padding: 5px 10px;
}
</style>
<?php
}
// Hook it!
add_action( 'admin_head', 'tmr_style_display' );