I have a user reference where the potential references are defined by a view. When a user creates a page, the list is populated with other users associated with that user via the view. The user is an argument and defaults to the logged in user.

When an admin edits the page, I need the view to display the users associated with the person that submitted the page not the users associated with the admin editing the page.

I accomplished this via implementing hook_form_alter() to supply the correct uid as an argument to the view:

$submitter = $form['uid']['#value'];
        $form['#field_info']['field_exempted_player']['advanced_view_args'] =
            $submitter;

And it works great when rendering the form.

When I save the form, I get an error telling me that I have an invalid user. This is because when content_field_invoke is called it creats fields from scratch rather than using the field that is in the form.

I've worked around this is userreference_field: When op is 'validate', use the field from the form (actually passed as the $teaser parameter) :

       // the form being validated
        $field = $teaser['#field_info'][$field['field_name']];
        $refs = _userreference_potential_references($field, '', NULL, $ids);
CommentFileSizeAuthor
userreference.module.patch.txt851 bytesbkat
Support from Acquia helps fund testing for Drupal Acquia logo