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.
Hi. When a user visits their profile they get a tab (menu_local_task) for "Newsletter Subscriptions" that lets them edit their newsletter subscriptions. I would like to move this form directly onto the user's edit profile page (so no more tab)... what would be the best way to go about this?
Comments
Comment #1
JordanMagnuson CreditAttribution: JordanMagnuson commentedOkay, I think I've figured this out. Can anyone verify whether this is the correct implementation?
Also, would you be open to a patch which would allow this placement as an option in the mailchimp settings, in addition to the tab placement?
First, alter the user profile form, ala the way Mailchimp alters the user registration form:
Then implement hook_user_presave to actually save the list information when the user saves their profile:
Comment #2
JordanMagnuson CreditAttribution: JordanMagnuson commentedHm... seems to be working to subscribe a user, not not to unsubscribe... any thoughts?
Comment #3
JordanMagnuson CreditAttribution: JordanMagnuson commentedStupid me. Instead of using hook_user_presave, I should have just added a submit handler to the user profile form. Here is my updated code, which seems to be working as desired:
Comment #4
nagiek CreditAttribution: nagiek commented@Jordan,
I'm doing the same thing and going about it the same way. However, you should try to standardize the form submits. Can't you write GlueCode instead?
Comment #5
JordanMagnuson CreditAttribution: JordanMagnuson commentedGood point nagiek, though I think the user account should be taken from the form, rather than using global $user, in case an admin is submitting the form for another user, or something. So:
Comment #6
JordanMagnuson CreditAttribution: JordanMagnuson commented@nagiek: are you getting "You have updated your settings in list x" every time a user saves their profile, regardless of whether they change their mailchimp settings?
I think this is a bug that becomes apparent in our use case, and have opened an issue at http://drupal.org/node/1788916
Comment #7
Khumbu CreditAttribution: Khumbu commentedcould this me coded as an option in the mailchimp settings...so the non so technical guys can use this too...
anyway thx
Comment #8
gcbMoving this to feature request queue -- seems more accurate at this point.
Comment #9
gcb#1548910: List checkboxes on user/edit