I manage an e-commerce website with two types of user roles for customers, retail and dealer. I have dealer setup as the only option in 'apply for role' module. After I approve an application (in 'Manage role applications'), I would like to be able to delete the approved role application without having the role removed (otherwise I will end up with a huge list of old applications). Currently the module deletes the application and the approved role when I hit delete from 'Manage role applications'. I have not found a module setting that controls this. Is there a way to delete only the application?
Comments
Comment #1
Soren Jones commentedIn case you haven't found it, the function that you want to look at is apply_for_role_remove_apply() in the apply_for_role module.
The line that deletes the roles from the user is:
apply_for_role_delete_role($uid, $rid);It sees like the best thing to do is to move the call to apply_for_role_delete_role() out of apply_for_role_remove_apply(), but that would be an API change.
So I've changed this to a feature request for an option to delete or archive approved role applications as that would keep the audit trail in place for those who want it.
Comment #2
Soren Jones commentedComment #3
Soren Jones commentedReactivating this. It at least needs documentation.
Comment #4
Soren Jones commentedActually this is already documented in line on the delete confirmation page:
And all of the functions need documentation, so I'm deleting that tag and moving this to 7 again.
Comment #5
not_Dries_Buytaert commentedWe at least need an option in '{domain}/admin/settings/apply_for_role' to show either all or only pending role applications in '{domain}/admin/user/apply_for_role'. Select 'only pending' value by default.
As suggested here (http://drupal.org/node/771548) we also need an option in '{domain}/admin/settings/apply_for_role' to automatically archive or delete role applications, after they have been approved or denied.
You rightfully quoted the 'apply_for_role_remove_apply' and 'apply_for_role_delete_role' functions from the 'apply_for_role.module' file of this module.
So, why couldn't you (as the maintainer of this module) alter your code? What does this have to do with (I guess you meant) this (http://api.drupal.org/api/function/user_roles/6) API?
This issue was originally submitted for the D6.x branch. Please, file another one for D7 or to request a port to D7.x, if needed.
Comment #6
not_Dries_Buytaert commentedForgot to change category and status too. Records of role applications should by themselves have nothing to do with records of roles.
Comment #7
Soren Jones commentedThat's your use case. Please read the explanation above. This is the expected behavior. It's documented by the designer. And it would be an apply_for_role API change (not a user_roles API change). A change would have very serious consequences for anyone using it as designed.
As a feature request and an API change request, this is unlikely to be changed in 6. This will most likely be addressed with a change to the admin UI in 7 and not to the API.
Comment #8
not_Dries_Buytaert commentedSry, if my limited technical knowledge causes any confusing or causes me to miss your point. Still, I fail to see why a "automatically delete user-role relationship, when deleting role application" checkbox option in in '{domain}/admin/settings/apply_for_role' could not easily be implemented without implications to existing users of this module (if the default value is set appropriately). A simple if-then around aforementioned apply_for_role_delete_role function of this branch would do just fine, wouldn't it?
Comment #9
not_Dries_Buytaert commentedOr following configuration options in '{domain}/admin/settings/apply_for_role' would do the trick:
a) show either only pending (default setting) or all role applications in '{domain}/admin/user/apply_for_role' and
b) not show (default setting) or show the "Delete role application" button in '{domain}/admin/user/apply_for_role'.
NB: Such change would only affects the web UI (not the API/ other modules) and not the current users either.
Comment #10
Soren Jones commentedThank you for clarifying your goals.
It should be possible to address both of these cosmetically in the theming layer.
Try this in a custom module:
Of course, it would still be possible to delete applications via the URL.
Comment #11
Soren Jones commentedIt seems that the solution to most of this issue would best be handled with #364247: Add integration with views, in which case hiding processed applications will be configured in Views.
However, it also seems that an additional permission should be added for deleting or resetting applications.
The permission shouldn't be checked inside apply_for_role_remove_apply(), but in any call to the function in the module.
That way anyone who wants to use the API directly from a custom module can do so without a permission check.
Comment #12
Soren Jones commentedFixed in 7 -dev. To be ported to 6.
Comment #13
jnicola commentedFixedin 7.x, won't be providing 6.x support.
Comment #14
jnicola commented