Users' data from users.data is moved to profile_values only after user data modification, but not after registration. So after registration users' fields are not searchable. I have made a quick and very dirty solution, which (through cron) periodically moves those datas to the right place.

header('Content-type: text/plain');
mysql_connect($host,$username,$password);
mysql_select_db($database);
// if strings are not retrieved utf8, then unserialize will fail
mysql_query("SET CHARACTER SET 'utf8'"); 

// collect field names and field ids to a hash
$qry = mysql_query('SELECT name, fid FROM profile_fields');
echo mysql_error();
$profile_fields = array();
while($row = mysql_fetch_object($qry)) {
    $profile_fields[$row->name] = $row->fid;
}
var_dump($profile_fields); // for diagnostic purposes

// select those users whose data is not in profile_values
$qry = mysql_query('select u.uid, data from users u left join profile_values pv on u.uid=pv.uid where pv.uid is null');
echo mysql_error();
while($row = mysql_fetch_object($qry)) {
    $data = unserialize($row->data);
    foreach ($data as $k=>$v) { // insert each user.data field as a row in profile_values like this: fid,uid,value
        if (empty($profile_fields[$k])) continue;
        $insert_qry = 'INSERT INTO profile_values VALUES ('.
            $profile_fields[$k] . ',' .
            $row->uid . ',"' .
            $v . '")';
        echo $insert_qry . "\n";
        mysql_query($insert_qry);
        echo mysql_error() . "\n";
    }

}

Comments

scor’s picture

There is a patch on the profile module that fixes that, hopefully it will be commited soon.

scor’s picture

There is a patch on the profile module that fixes that, hopefully it will be commited soon.
http://drupal.org/node/119114#comment-219903

tain’s picture

This didn't work for me...no change in my search results.

tain’s picture

The script returns an error on this line
foreach ($data as $k=>$v) { // insert each user.data field as a row in profile_values like this: fid,uid,value

davemybes’s picture

Status: Active » Postponed

It looks like the patch for the profile module got committed so that should solve this issue. Setting to postponed for now.

davemybes’s picture

Status: Postponed » Fixed

Please use the patch for the profile module to fix this issue.

Anonymous’s picture

Status: Fixed » Closed (fixed)