Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have added a hook_form_alter(), in a module I made, to my posting form for the time being:
function mymodule_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'my_formid_node_form') {
global $user;
if (!$form['taxonomy']['tags']['8']['#default_value']) {
$form['taxonomy']['tags']['8']['#default_value'] = $user->name;
}
}
}
Still, would be a nice feature to add.
EDIT: added a quick if statement (line 5) that checks to see whether the field is empty before filling it in. Otherwise it wipes out any old values one might have.
Relevant setting is not working for us. I even stripped the conditionals in author_taxonomy_form_alter() without success. Term textfield never gets the real author name or hardcoded test values when the node is saved.
And yes, we are using Ctools, but node/edit/% overrider is disabled.
Why I suspect Ctools that some other modules like HS also have/had trouble accessing or altering form values with Ctools enabled.
If I am missing something, sorry in advance.
Tx.
D 6.15, Ctools 6.x-1.x-dev (Jan 12), and others attached.
If an 'user name' is associated with an 'author term', then the linked 'author term' should be added to the list, not the 'user name', since they may differ.
IMO, this feature is incomplete and flaw
- shouldn't the username is appended to existing taxonomy list (author list) instead of overwritten? This help simulates multiple authors or at least that's my interpretation from the description "Automatically add username to author list"
- author term as in #7, example use case is RealName as author term that link to user account
- newly created author term should be automatically linked to the user account by default
Would gladly submit a patch if the above statements are correct.
Comments
Comment #1
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedI have added a hook_form_alter(), in a module I made, to my posting form for the time being:
Still, would be a nice feature to add.
EDIT: added a quick if statement (line 5) that checks to see whether the field is empty before filling it in. Otherwise it wipes out any old values one might have.
Comment #2
Robbie Sternenberg CreditAttribution: Robbie Sternenberg commentedAdded this feature. Thanks for the suggestion.
Comment #3
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedthanks for the addition. I will grab the new version soon!
Comment #5
chawl CreditAttribution: chawl commentedRelevant setting is not working for us. I even stripped the conditionals in author_taxonomy_form_alter() without success. Term textfield never gets the real author name or hardcoded test values when the node is saved.
And yes, we are using Ctools, but node/edit/% overrider is disabled.
Why I suspect Ctools that some other modules like HS also have/had trouble accessing or altering form values with Ctools enabled.
If I am missing something, sorry in advance.
Tx.
D 6.15, Ctools 6.x-1.x-dev (Jan 12), and others attached.
Comment #6
chawl CreditAttribution: chawl commentedPardon me...
Comment #7
dedalu CreditAttribution: dedalu commentedIf an 'user name' is associated with an 'author term', then the linked 'author term' should be added to the list, not the 'user name', since they may differ.
Thanks.
Comment #8
dedalu CreditAttribution: dedalu commentedFor #7, I propose this patch (attached).
Comment #9
ckngIMO, this feature is incomplete and flaw
- shouldn't the username is appended to existing taxonomy list (author list) instead of overwritten? This help simulates multiple authors or at least that's my interpretation from the description "Automatically add username to author list"
- author term as in #7, example use case is RealName as author term that link to user account
- newly created author term should be automatically linked to the user account by default
Would gladly submit a patch if the above statements are correct.