- ⌂ User
- Methods
User::get_initials()
Get the closest thing to a user's initials for a User based on which fields are defined.
This is helpful for producing the letter(s) that appear in a User's profile icon.
Prototype
string get_initials()
Return
A string based on the defined fields with the following preference:
- If a First Name and Last Name is defined, use the first letter from each.
- If only a First Name is defined, return the first letter.
- If only a Last Name is defined, return the first letter.
- If none of the above are defined, but a Username is defined, return the first letter.
- If none of the above are defined, but an Email is defined, return it the first letter.
- If none of the above are defined, return a question mark ("?").
Example
$users = $repo->get("FROM User WHERE Email!=''");
foreach($users as $user) {
echo($user->get_initials() . "\n" );
}