When a value in real name field in profile module is set once but deleted later, an empty string remains in database.
So when the function realname_make_name is called, isset returns true around line 267.

    if (isset($account->$name) && !$private_field) {
      $stuff['%'. $i] = $account->$name;
    }

This causes the return value of realname_make_name, and static var $users[$account->uid] to be an empty string, which later causes $node->name and $node->realname to be empty when the script goes through hook_nodeapi. So when I use theme('username', $node), the result is 'Anonymous', rather than the name of a registered user with a link. It also causes theme('username', $account) to display non-link with 'not verified'.

It took me a while to figure this out since I kept thinking I did something wrong in my customized theme.
Of course I can easily solve this issue by setting the realname field required, but in order not to let anybody else encounter the same problem, is it possible to use !empty instead of isset like the following?

    if (!empty($account->$name) && !$private_field) {
      $stuff['%'. $i] = $account->$name;
    }

I'm not sure if this change causes other issues, but it's been working for me. Thanks!.

Comments

NancyDru’s picture

Status: Active » Patch (to be ported)

You probably should have both "isset" and "!empty" because "empty" could raise a warning for those who have their error reporting set that way.

I will commit this to 5.x whenever someone tells me how the autocomplete testing is going.

andrenoronha’s picture

hey is it because of this that I have nothing at the user page html title and at the "to:" field of the contact form?

it's seems to me that the user who created their own account are not being recongnized as true authenticated users. Only the new users created by an admin account have their name at the html title of their page...

does realname have something to do with that??

NancyDru’s picture

A) Did they complete their profile fields?
B) What happens if they log out and back in?

andrenoronha’s picture

yes, the Realname field is mandatory.
And nothing happens when they logout and login...
when they're in their user page the html title shows "My accont" but when their user page is being viewed by another user the html title shows nothing...

redijedi’s picture

Version: 5.x-1.1 » 6.x-1.x-dev

Same problem for the 6x version. I upgraded to dev and still see the issue as of June 17.

redijedi’s picture

I found that auth'd users require the view user profiles permission. Now it seems to work ok.

andrenoronha’s picture

where can I set the view user profiles permission?
at my permissions page i don't see the conte profile module...

andrenoronha’s picture

i tried some tokens in the user page title pattern like user tokens and cck fields tokens
but the thing is, i integrated the user profile inside the user page. so cck fields are not shown in the user page title pattern.

so i used the token [user]. it shows the user name. but it should show de realname as this is its job.

help?

hass’s picture

Issue summary: View changes
Status: Patch (to be ported) » Closed (outdated)