Saving the URL during registration So I have created a drupal multisite install with a shared user database and I would like to store the site the user has signed up on. 

I have also created a view of user and I would like to filter them by site. Ideally I would like the view filter to be a dropdown, but it isn't essential.

I am already overriding the user_register_form via the template.php file, would it best to create a new text field for the user then hide and set it to the current domain via the template.php file?
Hope this will help you,

In Drupal 7

The best way to do is to create a new field for user registration form. Lets call the field as domain.

Steps:


Go to admin/config + Account settings + Manage Fields
Add new field

After adding

If you want to show this field in registration then check this


NOTE: If prefer do not show on registration form. May be there a chance to edit. Even though if your making it as disable, it can be change.

When ever the user registration form load, alter the form using hook_form_alter and give the default value for it.

function mymodule_form_alter(&amp;$form, $form_state, $form_id)  {
switch ($form_id)  {
    case 'user_register_form':
       //get field language
       $field_lang = field_language('user', 'field_user_domain');
       //assign default value
       $form['field_user_domain'][$field_lang['field_user_domain']][0]['#default_value'] = $_SERVER['HTTP_HOST'];
    break;
 }
}

When ever the users register the domain also saved.


You can use this field in views as per your requirement.