I have a script which creates a few nodes via node_save. The flow is something like this:

- create new user account using user_save()
- node_save($node1) ===> this has the field used by realname
- node_save($node2) ===> this node uses auto node title and the [realname-node-author] token

i get that this token requires $node2->nid which won't exist at this point so i simply do a another

- node_save($node2) - this time $node2->nid does exist

but the token still comes back as false.

but eventually i saw this was not surprising as even when my script is complete.. there is still no entry in the realname table for this new user. why not??

i can see that hitting certain pages cause the realname entry to be created; but i have tried programmatically things like node_load or even node_view on $node2 after it was created and this doesn't help.

I thought perhaps realname_make_name() was the trick but this also doesn't work as $user->homepage doesn't exist after creating $node2

i'm sure this is a trivial cache issue.. but wondering which cache entry to clear??

Comments

liquidcms’s picture

Title: What triggers realname creation? » realname creation is problematic
Version: 6.x-1.3 » 6.x-1.x-dev
Component: Tokens » Code
Category: support » bug
Priority: Normal » Major

changing this a bit from what i originally posted as i now think this is bug in how realnames are created.

on a different project than i reported on above.. but basically the same issue:

- i have a form which when submitted creates users (and their profile nodes from which realname is created)
- after submission i return to the form which uses a view to create a list of checkboxes based on users.. which includes the ones i just created.

issue is that the checkboxes of the new users are there; but without names.

the real issue... realname is doing some weird things here.

i can see that after my user_save i do in fact have an entry in the realname table, although it is not using the profile fields. but; by the time i get back to my form.. the entry has been deleted.

but.. as mentioned above.. hitting certain pages cause the realname to be built correctly.. i see comments in the code that suggest this is correct; that the code deletes the entry but suggests it will be built again next time it is required. well; it is required;but doesn't get built.

even doing a user_load after the user is created doesn't help... but... if i open a devel execute php window and do the same user_load call (the realname gets created) and then refresh my form page.. that user is now listed correctly.

i could likely sift through the code and sort out where realname needs to be re-inserting into the db.. but figured those more familiar would likely know immediately what the issue is.

hope this description helps.

hass’s picture

Issue summary: View changes
Status: Active » Closed (outdated)