Is it possible to login to Drupal with a custom user field, instead of username/pass? I have two websites - One of them is Drupal 7, and the other is a different site (Site #2). In Site #2, within the user tables, is a field called "customid". Each user on Site #2 has a unique, randomly generated 30 character alphanumeric string within their respective "customid" field.

I can pull the value of the "customid" field for the user on Site #2, and use it as an input value in a form post to the Drupal 7 site.

In the Drupal 7 site, I created a custom user field "customid" as well. 

Is it possible to make a form post from Site #2 to Drupal 7 - with the "customid" value as an input, and if it matches the "customid" field in the Drupal user table, log them in, else - redirect to the registration page? 

We're essentially bypassing the username/password to log them in - I'm trying to log them in via custom user field.

I searched everywhere, and just couldn't find anything where something like this had been discussed. Thanks anyone for your time and help!

UPDATE:
I've tried implementing W.M.'s solution below, however upon attempting to enable the module, I get the white screen of death. Nothing shows up in the logs for the error.

For my custom module, I have two files:
ra_login.module
ra_login.info

Info file:

name = RA Login
description = Check ID and Login if there is a match, else go to Registration Page.
core = 7.x

; Information added by Drupal.org packaging script on 2013-12-16
version = "7.x-1.0"
core = "7.x"
project = "ra_login"
datestamp = "1387203506"


Module File:

&lt;?php

function ra_login_menu()
{
    $items['authenticate-by'] = array( // or any other custom path you choose
        'title' =&gt; 'Login by SSO',
        'access callback' =&gt; true, // no point in authenticating at this point in code execution
        'page callback' =&gt; 'ra_login_function',
        'type' =&gt; MENU_CALLBACK,
        );
    return $items;
}

function ra_login_function($CONTACTID)
{
    // post the data to /authenticate-by as json with a parameter / property named CONTACTID holding the CONTACTID
    $postData = file_get_contents('php://input');

    $Data = json_decode($postData);

    $query = new EntityFieldQuery();
    $query-&gt;entityCondition('entity_type', 'user')
        -&gt;propertyCondition('uid', 1, '&lt;&gt;')
        // User number 1 should not be able to log in using this method
        -&gt;fieldCondition('field_contactid', 'value', $Data-&gt;CONTACTID, '=')
        -&gt;range(0,1);

    $result = $query-&gt;execute();

    if (isset($result['user'])) {
        $uid = array_keys($result['user'])[0];
        $account = user_load($uid);
        global $user;
        $user-&gt;uid = $uid;
        $user-&gt;name = $account-&gt;name;
        $user-&gt;timezone = $account-&gt;timezone;
        user_login_finalize(); // Log user in
        drupal_goto('/user'); // or any other path to redirect logged in users to
    } else {
        drupal_goto('/user/register');
    }

}


Again, for some reason when I try to enable the module, I get a white screen.
Thanks for anyone who can help!
UPDATE:
I turned on errors in php.ini - now instead of the white screen, it shows me the following error:

Parse error: syntax error, unexpected '[' in C:\inetpub\wwwroot\sites\all\modules\ra_login\ra_login.module on line 31 


Line 31 is:

$uid = array_keys($result['user'])[0];


Any help is greatly appreciated!
This is the code you need. In the Drupal site create the following module:

Update:

function my_special_login_menu()
{
    $items['authinticate-by-customerid'] = array( // or any other custom path you choose
        'title' =&gt; 'Login by customerid',
        'access callback' =&gt; true, // no point in authenticating at this point in code execution
        'page callback' =&gt; 'my_special_login_function',
        'type' =&gt; MENU_CALLBACK,
        );
    return $items;
}

function my_special_login_function($customerid)
{
    // post the data to /authinticate-by-customerid as json with a parameter / property named customerid holding the customerid
    $postData = file_get_contents('php://input');

    $Data = json_decode($postData);

    $query = new EntityFieldQuery();
    $query-&gt;entityCondition('entity_type', 'user')
        -&gt;propertyCondition('uid', 1, '&lt;&gt;')
        // User number 1 should not be able to log in using this method
        -&gt;fieldCondition('field_customerid', 'value', $Data-&gt;customerid, '=')
        -&gt;range(0,1);

    $result = $query-&gt;execute();

    if (isset($result['user'])) {
        $uid = array_keys($result['user'])[0];
        $account = user_load($uid);
        global $user;
        $user-&gt;uid = $uid;
        $user-&gt;name = $account-&gt;name;
        $user-&gt;timezone = $account-&gt;timezone;
        user_login_finalize(); // Log user in
        drupal_goto('/user'); // or any other path to redirect logged in users to
    } else {
        drupal_goto('/user/register');
    }

}


For this code to work you need Entity API module and you should serve the site over SSL in order to encrypt the data transferred between the two sites.