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 saw this on emf and I think it's an useful feature to have. I have defined an username field on the mailchimp list and I don't want that to be shown to either anon or auth users. Also, I'd like the name field to be displayed only for anon users.
I will try to contribute a patch for this thing.
Comments
Comment #1
netentropy CreditAttribution: netentropy commenteduse hook_form_alter from the Drupal api
Comment #2
hanoiiyeah well, it might be nice to have such a feature in a module for non-developers and to keep the module as flexible as possible.
Comment #3
levelos CreditAttribution: levelos commentedGreat idea, but I think it's a fairly fringe use case, and the interface is already very busy, this would make it more so. I'll consider a patch, but am hesitant to include this. Indeed, it's exactly what hook_form_alter() is for.
Comment #4
hanoiiI don't mind throwing a form_alter in a module, but again, that's something that I will do and will not help anybody else. But as you say, it might just be me who needs it. I'd think the issue is better to leave it as postponed so it can be found and eventually, if others needs this, we can resume discussion. I guess if your position is not to include such a feature, I will do it as my own module.
Comment #5
levelos CreditAttribution: levelos commentedAgreed on leaving it postponed. If you want to submit a patch, for that matter, I'd be happy to consider for inclusion. Thanks.
Comment #6
KMNL CreditAttribution: KMNL commentedOften I want to sync user profile info once they complete the registration process, but in the sidebar, only the email is required. (I'd prefer to not use CSS to hide elements). Hook form alter sounds like a temp fix to me.
Comment #7
davepoon CreditAttribution: davepoon commentedYou can easily create a custom module using form_alter hook to hide the fields you don't want in a form,
find out the form ID, find out the fields in the array you want to hide,
you can use dsm($form) if you are using devel module, or simply use print_r($form) to print out the array.
The following code sample is to hide the first name and last name fields in the subscription block.
Comment #8
Michsk CreditAttribution: Michsk commentedactually its
Comment #9
Michsk CreditAttribution: Michsk commentedmm, actually that doesn't work.
Comment #10
Michsk CreditAttribution: Michsk commentedlol, seems i forgot to reference the $form in the function.
Comment #11
levelos CreditAttribution: levelos commentedThis feature is now available in 2.11.
Comment #12
levelos CreditAttribution: levelos commented