-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathacp-select-formatter-user_name.php
42 lines (35 loc) · 1.23 KB
/
acp-select-formatter-user_name.php
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
<?php
/**
* This filter modifies the user name that is shown when opening the select2 dropdown menu when selecting a user.
* For example, this select2 menu is used by inline editing and smart filtering when selecting a user from the dropdown menu for the Author column.
* The default displayed value is: <First Name> <Last Name> (<Email>) e.g. 'Tobias Schutter ([email protected])
*/
/**
* @param string $label Default is <First Name> <Last Name> (<Email>) e.g. 'Tobias Schutter ([email protected])
* @param WP_User $user
*
* @return string
*/
function acp_select_formatter_user_name($label, WP_User $user)
{
// Modify label
// $label = $user->user_login;
return $label;
}
add_filter('acp/select/formatter/user_name', 'acp_select_formatter_user_name', 10, 2);
/**
* Display the user's fullname when using the select2 dropdown menu
*
* @param string $label
* @param WP_User $user
*
* @return string
*/
function acp_select_reformat_username_to_fullname($label, WP_User $user)
{
if ($user->first_name || $user->last_name) {
$label = trim($user->first_name . ' ' . $user->last_name);
}
return $label;
}
add_filter('acp/select/formatter/user_name', 'acp_select_reformat_username_to_fullname', 10, 2);