Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
drupal.org
realname
Commits
60f14e3e
Commit
60f14e3e
authored
Nov 23, 2010
by
Dave Reid
Browse files
by Dave Reid: Re-load account objects that were not properly loaded.
parent
86d8e5fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
realname.module
View file @
60f14e3e
...
...
@@ -46,16 +46,30 @@ function realname_menu() {
function
realname_username_alter
(
&
$name
,
stdClass
$account
)
{
static
$in_username_alter
=
FALSE
;
if
(
empty
(
$account
->
uid
))
{
// Don't alter anonymous users or objects that do not have any user ID.
return
;
}
// Real name was loaded/generated via hook_user_load(), so re-use it.
if
(
isset
(
$account
->
realname
))
{
if
(
drupal_strlen
(
$account
->
realname
))
{
// Only if the real name is a non-empty string is $name actually altered.
$name
=
$account
->
realname
;
}
return
;
}
elseif
(
!
$in_username_alter
)
{
// Because realname tokens may execute format_username() we need to prevent
// recursion from happening.
// Real name was not yet available for the account so we need to generate it.
// Because tokens may call format_username() we need to prevent recursion.
if
(
!
$in_username_alter
)
{
$in_username_alter
=
TRUE
;
if
(
$realname
=
realname_load
(
$account
))
{
// If $account->realname was undefined, then the user account object was
// likely not properly loaded.
$realname_account
=
user_load
(
$account
->
uid
);
if
(
$realname
=
realname_load
(
$realname_account
))
{
$name
=
$realname
;
}
$in_username_alter
=
FALSE
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment