Whith a custom module, I'd like to update some nodes uid whenever a content type is updated. I triple checked, and my database update function is called, as "changed" field is updated each time, and I send myself a mail to check that the data passed is correct.
I don't know how to call the equivalent of mysql_query() or die()
, and don't manage to debug that.
I have only a notice:
Undefined index: #language dans
locale_field_node_form_submit()
.
function zen_custom_form_alter(&$form, &$form_state, $form_id) {
global $user;
switch($form_id){
case 'lieux_de_pratique_node_form':
if (in_array('Admin dojos', array_values($user->roles))) {
// some stuff
$form['#submit'][]='set_dojos_manager';
// ...
}
// ...
}
// ...
}
function set_dojos_manager($form, &$form_state) {
$dojo_editeur = $form['field_dojo_editeur_web']['und'][0]['uid']['#default_value'];
$dojo = $form['nid']['#value'];
$uid_updated = db_update('node')
->fields(array(
'uid' => $dojo_editeur,
))
->condition('nid', $dojo)
->execute();
mail('my_email', 'test', $dojo_editeur . ' / ' . $dojo);
}
}