Hi,

The module I'm writing saves a custom user attribute with user_save. From another system with soap i get this attribute returned and i need to resolve user->uid from this customer attribute. How would this be possible? I have tried user_load() but this only searches in the existing 'normal' columns and not the serialized data column.

Thx,

Carlo

Comments

epicflux’s picture

A couple approaches:

Total DIY:

Set up your own DB table, then in a custom module use a hook_user function to interact with the user module.

Less DIY:

Enable the core Drupal Profile module. Create a profile textfield where you can save this customer attribute. You may still have to write your own DB query to get the user id from the profile tables, but it wouldn't require as much coding, and the data won't be serialized.

clandmeter’s picture

Thanks for your reply.

What I did now is the following:

function modulename_load_user($custid) {
  $query = db_query("SELECT * FROM {users}");
  while($row = db_fetch_object($query)) {
    $data = unserialize($row->data);
    if ($data['module_id'] == $custid) {
      return $row;
    }
  }
  return FALSE;
}

On a large user table this will not be very resource friendly but for my own use its ok.

-Carlo