Is it possible to extend this module to user reference? Or is there another module with this feature?

Comments

osopolar’s picture

Have you considered to use the Content Profile Module to create user-profiles and set the node-reference to the users content-profile-node instead to the user himself?

osopolar’s picture

It would be nice to have a real user reference, because the content-profile-approach only works in cases where you can be sure that the content-profile already exists.

quicksketch’s picture

Status: Active » Closed (won't fix)

This won't be happening in this module (it's called "Node Reference URL Widget" for a reason).

nathaniel’s picture

Solution:

Place this code as the default for your user reference field then pass the uid as an argument in the url.

node/add/content-type/uid

Default value
PHP code

<?php


if (is_numeric(arg(3))==TRUE) {
return array(
  0 => array('uid' => arg(3)),
);
} else {
return array();
}


?>

ocamp’s picture

where do I put this code?

finex’s picture

On the "default value" field in the field settings page

NickWebman’s picture

Try using http://drupal.org/project/prepopulate to pre-populate the user reference field.

Install the References and Prepopulate module.

Note: Make sure to use a text field for the user reference field instead of a dropdown.

Let's use the example of associating musicians (users) with their songs (new content-type named "songs"). Pretend each musician has a user profile/is a user. On each musician's profile, let's add a link that lets us create a new song node. It will look something like...

http://yoursite.com/node/add/song?edit[field_user_reference][und][0][uid...

Now, if you follow that link, on the song creation page, the user reference field will be pre-populated with the user name "Buddy Holly". If you hide the user reference field with CSS (bad practice, I know), you'll be in business.

Note: this assumes you named your user reference field "user reference". If not, make sure the appropriate system name of the user reference field you created on the song content-type is reflected in the url example provided above.

As for making the last bit (the username / Buddy%20Holly) dynamic, I'm not sure. There's gotta be a way.

Works for D7. Not sure about D6.

sisko’s picture

I have the same problem of trying to link to a USER rather than a NODE.

Currently, I am using the CONTENT_PROFILE module which I can use with NODEREFERENCE_URL. But then I will have orphan content profiles because they will not actually be related to a user.

Is there a way to get a USER to be created along with a content profile using nodereference_url ??

mkadin’s picture

Since in D7 user's have content fields just like nodes do...it does seem like it makes sense as a feature. I'd be willing to help put it together for D7 if you're interested.