function content_profile_page_edit($type, $account) {
  ....
  if (!$node) {
    $node = array('uid' => $account->uid, 'name' => (isset($account->name) ? $account->name : ''), 'type' => $type, 'language' => '');
  }
function node_object_prepare(&$node) {
  ...
  if (!isset($node->nid)) {
    ...
    $node->uid = $user->uid; // eeeekkkkkkkk
    $node->created = time();

http://api.drupal.org/api/function/node_object_prepare/6

I have a sinking feeling this is a duplicate but couldn't find it, sorry if that's the case.

Patch resets the uid based on name in prepare.

Comments

hefox’s picture

Status: Needs review » Needs work

Right, if statement above will sometimes invalidate if statement below.

hefox’s picture

Status: Needs work » Needs review
StatusFileSize
new858 bytes

Updated patch, haven't tested other than passing validation, but using similar code elsewhere.

YK85’s picture

subscribing

hefox’s picture

That user_load should likely be

  $uid = db_result(db_query("SELECT uid from {users} where name = '%s'", $node->name));

user_load isn't cached.

However, the patch is still valid, it could benefit more from being reviewed.

YK85’s picture

The patch worked great =)
Anyone else able to review?

vkareh’s picture

StatusFileSize
new1.34 KB

I found that I also needed to set the form value for name and uid during form alter, depending on how you are passing the other user's uid in the URL.

I guess that also has to do with the fact that there are different URLs for the same thing in this module. I attached a patch that includes my additions as well.