All methods I find to make new tokens seem to fail on the most recent Drupal, has anyone else experienced this?

If I make a trivial module to add them in the way described in all tutorials, e.g. this one, and I end up with the following errors.

    Notice: Undefined property: stdClass::$field_firstname in kajira_tokens_tokens() (line 42 of /var/www/kajira/sites/all/modules/kajira_tokens/kajira_tokens.module).
    Notice: Undefined property: stdClass::$birthdate in kajira_tokens_tokens() (line 45 of /var/www/kajira/sites/all/modules/kajira_tokens/kajira_tokens.module).
    Notice: Undefined property: stdClass::$college in kajira_tokens_tokens() (line 49 of /var/www/kajira/sites/all/modules/kajira_tokens/kajira_tokens.module).

Any idea what would cause this or what is missing in these tutorials?

Comments

nevets’s picture

Without seeing the code it is hard to be sure but it would appear you have code something like $object->field_firstname and $object does not have the field/member field_firstname.

P3t3r’s picture

That was a golden hint, problem is solved now, thanks!
The problem was that my fields were not in $user, but I had to do

$user_data = user_load($user->uid);

and grab them from $user_data.