w3all and WooCommerce Memberships

brianp6
User w
User w
Posts: 6
Joined: Thu Aug 15, 2024 8:10 pm

w3all and WooCommerce Memberships

Post by brianp6 »

Hi,

I wonder if you can help me.
I have read your instructions on using a custom wpRoles_phpbbGroups.php file to do appropriate mapping between WP roles and phpbb groups. This seems to be working well when I test it from the WP Dashboard. However, it doesn't seem to fire the same process when in WooCommerce.

Scenario
I set a WP user to be role 'customer'.
In WooCommerce Memberships, I put the user on a membership plan.
WooCommerce adds in a new role to the user. The user's Role(s) are now both 'customer' and 'subscriber'
When the 'subscriber' role is added, the custom wpRoles_phpbbGroups.php file is not executed.

Any ideas? Perhaps I'm missing a setting somewhere that I've not found yet.
Many thanks.
User avatar
axew3
w3all User
w3all User
Posts: 2881
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: w3all and WooCommerce Memberships

Post by axew3 »

Hello! I will surely test (if i understand exactly what)
so you say that an user that you have as Customer only, is then set as Subscriber, but it do not work in woocommerce.
To be subscriber the user need to activate a (maybe free) membership?
Or do you mean an action done by an admin via admin? I assume this by your post: anyway i will check asap and return back here.
I will try an example
brianp6
User w
User w
Posts: 6
Joined: Thu Aug 15, 2024 8:10 pm

Re: w3all and WooCommerce Memberships

Post by brianp6 »

Hi and thanks,

A user has the 'customer' role. This is the starting point.

In WooCommerce, they are then allocated a membership plan - for the test I did this manually from within WooCommerce, but in reality it would be when the user performs a membership "purchase", this could be free or paid, but the WooCommerce Membership at this point adds a new role to the user automatically so that 'subscriber' is now added automatically giving the user two roles.

I don't see any execution of the wpRoles_phpbbGroups.php file.

I was wondering ... is it because you're using the profile_update hook and such a change by WooCommerce would need the add_user_role hook? (or maybe even the set_user_role hook if it used that in other circumstances).

Thanks.
User avatar
axew3
w3all User
w3all User
Posts: 2881
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: w3all and WooCommerce Memberships

Post by axew3 »

First of all, i've find out an error, that is into the
/wp-content/plugins/wp-w3all-phpbb-integration/class.wp.w3all-phpbb.php
PHP Warning: Undefined variable $w3all_custom_output_files in class.wp.w3all-phpbb.php on line 523
to fix, so to let exec the code as it need to be, until the next plugin version is not released, please open:
/wp-content/plugins/wp-w3all-phpbb-integration/class.wp.w3all-phpbb.php
and just after

Code: Select all

private static function verify_phpbb_credentials(){
add

Code: Select all

global $w3all_custom_output_files;
or add the var $w3all_custom_output_files (as it will be) into the list of all others declared global vars:

Code: Select all

global $w3all_custom_output_files,$w3all_link_roles_groups,$w3all_phpbb_profile_fields, ... ... etc etc
or the code on verify_phpbb_credentials() will not fire so to load the custom file, but the default one.
Are you using a custom one?

Anyway this is the part on verify_phpbb_credentials() that run for the logged in user, that check for phpBB groups which the user belong to, and update in WP the role based on the related code)
it is not about the update done on WP admin by the same user or an admin.
Let see what happen on admin action or due to user's action.

Looking also for WOO hooks so to know how to make the joke easier.
Or the WP default filter, that fire when a role change, i assume, it will be faster to code on it all the required joke.
Let see...
brianp6
User w
User w
Posts: 6
Joined: Thu Aug 15, 2024 8:10 pm

Re: w3all and WooCommerce Memberships

Post by brianp6 »

Excellent, that has fixed it.

I also hadn't enabled the setting:
"Use custom files to display Last Topics Widgets, Login Widget and Shortcodes"

Because in the instructions it said ........
"Note that the option Use custom files to display Last Topics Widgets, Login Widget and Shortcodes do not affect this. If the custom file /wp-content/plugins/wp-w3all-custom/wpRoles_phpbbGroups.php exist, it will be included, even if the Use custom files to display Last Topics Widgets, Login Widget and Shortcodes option is set to No."

However, I can see that you are verifying credentials on every single page load via the 'init' hook, so I needed this enabled, and now with your code fix it is working. The WooCommerce changes to the member's role is picked up the next time the member logs in.

Perhaps the instructions need updating :-)

Very many thanks.
Brian.
User avatar
axew3
w3all User
w3all User
Posts: 2881
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: w3all and WooCommerce Memberships

Post by axew3 »

Ok! and glad that it worked, i'm just over to re-test and i was asking me various things because i did not check this by long time now.
It is very easy to switch the code so to not load verify_credentials each time.
I will return again in reply, if any question or new bug just post please!
Post Reply