I have been working on this issue for quite some time now, and am really struggling.
Is it possible to modify a node's UID as it's submitted?
I have a CCK content type that I want some users (employees) to be able to submit for other users (clients) - the problem is that Drupal seems to be over riding the UID I set for the node, with the creating users UID. This seems like it should be easy, but I can't seem to catch the form submission at the right point.
Here is what I'm working with...
<?php
function addSR_form_service_request_node_form_alter(&$form, $form_state) {
if (arg(0) == 'user' && is_numeric(arg(1))) {
$form['#submit'][] = 'addSR_submit_function';
}
}
function addSR_submit_function($form, $form_state) {
$account = user_load(arg(1));
$form_state['values']['uid'] = $account->uid;
$form_state['values']['name'] = $account->name;
}
?>
The form I'm altering is in a block, and it's showing up and calling the form_alter (I checked this with drupal_set_message).
Can someone please point me in the right direction on this..? Or tell me that it is impossible?
Comments
Comment #1
bigplanet commentedWell, no help from Drupal.org - Glad I figured it out. I guess I'll post the solution here for anyone who comes across this issue.
The answer is to change $form_state to &$form_state, as the pass by reference is needed to alter the value.
As a side note, the forums, issues, and overall support on Drupal.org is terrible. For as awesome as Drupal is, the people that lurk around here are real A-holes - you're more likely to get scolded for putting your post in the wrong place than to receive help. And who can blame people for putting their post in the wrong place the support areas of this site are atrociously convoluted, and probably only understood by the A-holes that will yell at you when you mess up!
I recommend stackoverflow.com for drupal help - the developers are smarter, and nicer!
Comment #2
kars-t commentedHi
I am closing this issue to clean up the issue queue. Feel free to reopen the issue if there is new information and the problem still resides. If not please make sure you close your issues that you don't need any more.
Maybe you can get support from the local user group. Please take a look at this list at groups.drupal.org.