Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.
function sms_user_delete($uid, $number = FALSE) {
  userfieldmobil_user_update($account->uid); // my custom field about users i call this manually. 
  $query = db_delete('sms_user')
    ->condition('uid', $uid);
  if ($number) {
    $query->condition('number', $number);
  }
  $num_deleted = $query->execute();
}

function userfieldmobil_user_update($uid) { // i make it manually not able to update this
$num_updated = db_update('field_data_field_mobilnumber')
->fields(array(
'field_mobilnumber_value' => '',
))
->condition('entity_id', $uid, '>=')
->execute();
}

What i'm doing wrong sms_user delete OK but my custom field has value but not updated.

share|improve this question
    
are you trying to set field_mobilnumber_value to 'nothing ' when user deleted? –  neok Dec 25 '12 at 15:51
    
thanks because uid is null if i dont write in sms_user_delete you're right –  turkaze Dec 25 '12 at 16:01
add comment

1 Answer 1

up vote 2 down vote accepted

If you want to update your field when user was deleted you should put your update query into your sms_user_delete. Because userfieldmobil_user_update will only works if u update user data, not delete it.

function sms_user_delete($uid, $number = FALSE) {
  userfieldmobil_user_update($account->uid); // my custom field about users i call this manually. 
  $query = db_delete('sms_user')
    ->condition('uid', $uid);
  if ($number) {
    $query->condition('number', $number);
  }
  $num_deleted = $query->execute();

  $num_updated = db_update('field_data_field_mobilnumber')
     ->fields(array(
     'field_mobilnumber_value' => '',
     ))
     ->condition('entity_id', $uid, '>=')
     ->execute();
  }

Its not like in drupal 6 where u can use hook_user, read about hook_user_update and hook_user_delete for more info.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.