Hey there,

I have noticed that the multiple checkboxes fields i have set in my Profile, and have displayed on my registration form aren't saving to the database (i am checking the {profile_fields} table). Is there something i am missing here? Or any other explanation as to why this is happening?

Thanks
Craig

Comments

johnhanley’s picture

Thanks for bringing this to my attention. I'm not sure how this slipped past me or why it wasn't discovered sooner.

I have identified the source of the problem and will have a new development snapshot available soon.

John

barber75’s picture

Hey!

I dug around the code, and it seems it is related to the 'me' module. As, when grabbing the arg(1), it was passing my 'me' value instead of a physical uid. Hence, when writing to the database, it doesn't know for what user to save to, so doesn't get written. This is also the same for loading in set variables for a user....

I believe there is a patch for this right?

thanks for replying! Sorry, i meant to close this thread, but i got totally sidetracked!

cheers again
Craig

johnhanley’s picture

Hi Craig,

Thanks for the additional information.

The development version has a fix for the me aliases module. However your bug report revealed another problem that needs to be corrected as well. I'll be checking in a fix within the next couple of days and will update this issue at that time.

Thanks again,
John

seahostler’s picture

Subscribing. :) I had the me module installed, as well. Thanks for rocking on this, John.

johnhanley’s picture

Assigned: barber75 » johnhanley
iLLin’s picture

Shouldn't your uid lookup come from the account passed with the form?

      //$uid = (module_exists('me') && arg(1) == 'me') ? $user->uid : arg(1);
      // should be this?
      $uid = $form['_account']['#value']->uid;

Reason why I bring this up is if I call the form myself on w/e page I want, your code doesn't work as it's look towards the URL. For instance:

$form = drupal_get_form('user_profile_form', $account, 'Basics');
return $form;

Thoughts on this?

iLLin’s picture

Also if an admin was editing a form, this wouldn't work either.

johnhanley’s picture

@iLLin,

I took your advice and made the indicated change--thanks!

@barber75,

The issue you originally reported has been fixed as well.

If you and anyone else could kindly test the newest dev snapshot. I believe this version is ready for release.

Regards,
John

savedario’s picture

Thanks for fixing this.
I installed the dev version and ran update.php.
It even picked up multi-choice values that were saved but not displayed.

johnhanley’s picture

Status: Active » Closed (fixed)

Fixed in the 6.x-2.0 release.

nnevill’s picture

Version: 6.x-1.2 » 6.x-2.2
Priority: Critical » Major
Status: Closed (fixed) » Active

after debugging i found that data from multicheckboxes save into users table but module logic based on that data save into profile_values table.
to fix it i've added implementation of hook_user to my module:

/**
 *  Implementation of hook_user().
 */
function mymodule_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'update':
        return mymodule_save_profile($edit, $account);
    case 'insert':
      return mymodule_save_profile($edit, $account);
  }
}


/**
 *  Update/insert function for multi checkboxes.
 */
function mymodule_save_profile(&$edit, &$user) {
  $q = db_query("SELECT pf.name, pf.fid FROM {profile_checkboxes} pc 
                INNER JOIN {profile_fields} pf ON pf.fid = pc.fid
                WHERE pc.type = 'checkboxes'");
  while ($r = db_fetch_array($q)) {
    if (in_array($r['name'], array_keys($edit))) {
      db_query("DELETE FROM {profile_values} WHERE fid = %d AND uid = %d", $r['fid'], $user->uid);
      db_query("INSERT INTO {profile_values} (fid, uid, value) VALUES (%d, %d, '%s')", $r['fid'], $user->uid, $edit[$r['name']]);
    }
  }
}

so multiple checkboxes values save correctly now

johnhanley’s picture

Status: Active » Closed (fixed)

Thanks for your contribution, but unless you're submitting a patch for Profile Checkboxes this issue is still closed.