I have a Drupal 5.5 site with eC 5.x-3.4 and the ec_roles don't seem to be working as expected.
The problem:
I have a product that when purchased adds a role to the user. When I look at the user list it clearly states that the user is in the new paid role. When the user views the site, they don't have the new role. It appears as if the user role information is cached and not getting cleared when the role change takes affect. The user can log out and log back in and that does not resolve the problem.
Expected behavior:
I expected the role to immediately be added to the user as it is and also enabled so the user can access the new content.
The current work around:
If I edit the user from the user list and use the save button, then the user instantly has the new role though I have actually changed nothing in the user page.
When I checked the code in the ec_roles in ec_roles_atpurchase() I don't see any flushing of the cache or rebuilding of the roles.
Looking into user.module in user_save() there is a call to sess_destroy_uid() right after the roles change. Then a call into user_load() which appears to reload all the new data. I'm just wondering if there needs to be a reloading of the user data or killing off their session (I thought logging out and back in killed the session) after the roles are changed.
Any tips on this would be helpful.
Comments
Hi Scott, If it's any help,
Hi Scott,
If it's any help, I'm using 5.6 with ec_role 5.x-3.x-dev and it's working properly. It is definitely adding and enabling the role as soon as the transaction is finished.
Barry
thanks
Thanks for the comment, I didn't realize that there was a 5.x-3.x-dev version. It is way way down the list of available versions, but I finally found it.
For reference, the fix was put in the dev version and consists of the following line:
cache_clear_all("{$txn['uid']}:", 'cache_menu', TRUE);
That was added at the end of the ec_roles_atpurchase() function which does what I suspected was needed.