I am writing a function (in CVS HEAD) to create custom profile categories & fields for specific roles. In particular, certain user profile categories will only be available to certain user roles.
I'm creating a hook_user call to a custom category lister. However, it seems that when hook_user is called with $op == "categories", you don't have access to the current $user. Is this correct? If so, is there another way I can send certain categories for certain user roles?
Here's my code:
function profile_custom_user($type, &$edit, &$user, $category = NULL) {
switch ($type)
{
case 'form':
return profile_custom_form($edit, $user, $category);
case 'categories':
return profile_custom_categories($user);
}
}
function profile_custom_categories($user) {
// The following works correctly
$data[] = array('name' => 'Test Profile', 'title' => 'Test Profile', 'weight' => 4);
// The following doesn't get called
if ($user->uid == 1)
{
$data[] = array('name' => 'Admin Test Profile', 'title' => 'Admin Test Profile', 'weight' => 4);
}
return $data;
}
function profile_custom_buyer_form(&$edit, &$user, $category)
{
// This works properly, to test that $user is sent properly with other $ops in hook_user
if ($user->uid == 1)
{
$form[test] = array('#type' => 'fieldset', '#description' => 'Administrator Account');
}
return $form;
}
Thanks for any feedback.
- Aaron
Culture Fix Web Identity & Design
Digital Folk Art (my blog)