The implementation of hook_user (nodeaccess_password_user) does not make use of the $category parameter, which means that the passwords field appears on every tab on the profile form.

I believe this is a bug as profile forms belong to category that determines which tab they appear on, thus the behaviour here is inconsistent.

I do realise that the passwords field is not a real profile field and thus does not have a category, but this could easily be worked around by having an additional setting on the settings page called something like "password field profile category" stored in variable: nodeaccess_password_profile_category

the nodeaccess_password_user function could then be modified like:

Old version:
function nodeaccess_password_user($op, &$edit, &$account, $category = NULL) {
if ($op == "form" || $op == "register") {
$form = array();
...
New version:

function nodeaccess_password_user($op, &$edit, &$account, $category = NULL) {
$password_field_category = variable_get('nodeaccess_password_profile_category', 'account');
if (($op == "form" && $category == $password_field_category) || $op == "register") {
$form = array();
...

This is the first time I have raised an issue so I hope I have done it correctly.

Comments

danielb’s picture

Yup good point, although it would be easier to just hardcode it to 'account' rather than in a variable - anything wrong with that?

grahamu’s picture

I don't think it should be hard-coded to 'account'. Not that that would be the end of the world, just that it would be very easy to create setting and then use a variable, that way the user get to choose where it should appear on the profile form. Having the passwords field only available on the first tab of the profile form may not suit the users particular use case.

I am happy to put a quick patch together for this. Hopefully in the next few days.

danielb’s picture

Is there a way to create a list of options of possible categories on the config page? I suppose this data would exist somewhere.

grahamu’s picture

profile_categories() would do it on drupal 6.
http://api.drupal.org/api/drupal/modules--profile--profile.module/functi...

On drupal 7, the same function is called profile_user_categories().
http://api.drupal.org/api/drupal/modules--profile--profile.module/functi...

This returns an array of category arrays from which you can extract the category names.

Sorry, I've not been able to get around to creating a patch yet.

danielb’s picture

Title: nodeaccess_password_user function does not respect $category parameter » Support Profile module category
Version: 6.x-3.3 » 7.x-4.x-dev

Added to 6.x-3.4.

Now I have to figure out what to do about this in Drupal 7.

danielb’s picture

Version: 7.x-4.x-dev » 6.x-3.3
Status: Active » Fixed

Added to my dev copy of 7.x-4.x, will commit soon.
Reverting issue version back and marking as fixed.

grahamu’s picture

Thanks very much for fixing this and sorry I never got around to proving a patch for the issue.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.