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.
API page: http://api.drupal.org/api/drupal/modules%21user%21user.api.php/function/...
> Retrieve a list of user setting or profile information categories.
A hook rarely if ever 'retrieves'. This surely *defines*.
Comments
Comment #1
joachim CreditAttribution: joachim commentedWhile we're at it, some documentation on how to actually make use of this would be good.
A category defined here should then be created by implementing hook_form_FORM_ID_alter for the form ID 'user_profile_form', in which:
Comment #2
jhodgdonYes, sounds like a good thing to fix! Apparently this mess has finally been eliminated in Drupal 8, so this is a D7 issue only unless we want to apply the fix to hook_user() in D6 as well.
Comment #3
cferthorneyPatch attached. This is my first API patch, so I hope i have done this correctly.
Comment #4
michaelmol CreditAttribution: michaelmol commentedPatch looks fine, make sure you set the status to needs review when attaching a patch that needs review.
Comment #5
michaelmol CreditAttribution: michaelmol commentedComment #6
jhodgdonThanks for the patch!
For hook documentation, the first line should be "Define..." not "Defines":
http://drupal.org/node/1354#hooks
Comment #7
cferthorneyAdjusted and resubmitted
Comment #8
jhodgdonLooks good!
Did you notice comment #1 on this issue though? A request was made that we should say something in this hook documentation about what else a module would need to do after implementing this hook... maybe we should do that?
Comment #10
michaelmol CreditAttribution: michaelmol commented#7: description_of_hook_user_categories_is_incorrect-1842528-7.patch queued for re-testing.
Comment #11
jhodgdonSee #8.
Comment #12
cferthorneyHaving read the Documentation standards for code examples [api.drupal.org], I hope this is right. I wasn't 100% certain if the @code/@endcode went before or after the @return code. But please see attached patch and let me know if I need to reorganize it.
Comment #13
cferthorneyForgot to set status as 'needs review'
Comment #14
jhodgdonThe syntax is fine (except that you need a blank line after the @endcode and before the @return).
But I don't think this gives accurate information as suggested in #1. The idea is that:
a) First you implement the hook we're documenting here, hook_user_categories().
b) Then you need to implement hook_form_FORM_ID_alter for the form ID 'user_profile_form'.
c) In that function, the given code snippet needs to be placed so that you are adding some form elements to the user profile form for your category.
Comment #15
donquixote CreditAttribution: donquixote commentedI just came across this, while trying to register a sub-page user/%/edit/something using regular hook_menu(), and being confused what hook_user_categories() is doing there.
Maybe we should also document how you can disable the feature altogether, e.g. with hook_menu_alter() to change the user/%/edit/account wildcard loader?
If you want to do something that works generically for all entity types, then this "feature" is in the way.
Comment #16
owenpm3 CreditAttribution: owenpm3 as a volunteer commentedHow does this look?
Comment #17
jhodgdonThanks for reviving this issue! Accuracy-wise, the patch looks fine. There are several formatting problems though:
This will not format correctly in the API documentation parser. Use a bullet list instead. See
https://www.drupal.org/node/1354#lists
for formatting information.
End the first line in : and eliminate the blank line.
This will take up less space if you do not indent the code by 2 spaces.
Comment #18
joachim CreditAttribution: joachim commentedI'd just like to say in passing that the level of detail and explanation added in patch #16 is really good. Massive improvement to our documentation!
Comment #19
owenpm3 CreditAttribution: owenpm3 as a volunteer commentedI believe I corrected the formatting issues.
Let me know if I've missed anything. And thank you for the feedback.
Comment #20
jhodgdonGreat, nearly perfect! Just a couple of very minor things to fix and I think this will be good to go:
End this line (before the list) in :
End this in .
End this line in .
Comment #21
owenpm3 CreditAttribution: owenpm3 as a volunteer commentedSweet. Patch has been updated.
Comment #22
jhodgdonLooks good!
For next time - it's nice when you upload a new patch to (a) set issue to Needs Review and (b) provide an interdiff file. No worries this time. Thanks!
Comment #23
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedCommitted to 7.x - thanks!