Skip to content

Commit

Permalink
Update user_get_name() to handle deleted users
Browse files Browse the repository at this point in the history
The new logic involve not only getting name for non-existent user, but usernames as well.
So harden user_get_username() to handle non-existent users.
  • Loading branch information
vboctor committed Feb 7, 2018
1 parent 4f8ed47 commit 3b41e69
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/user_api.php
Expand Up @@ -937,7 +937,12 @@ function user_get_email( $p_user_id ) {
* @return string
*/
function user_get_username( $p_user_id ) {
return user_get_field( $p_user_id, 'username' );
$t_row = user_cache_row( $p_user_id, false );
if( false == $t_row ) {
return lang_get( 'prefix_for_deleted_users' ) . (int)$p_user_id;
}

return $t_row['username'];
}

/**
Expand Down

0 comments on commit 3b41e69

Please sign in to comment.