Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
81 stars 29 forks source link

A user with role: -No role for this site- becomes Admin after signing up for a sub #463

Closed jacoswan closed 1 year ago

jacoswan commented 1 year ago

Describe the bug

WordPress has various user roles, one of which is - No role for this site -. When that is set, if the user buys a Subscription product, their user role is changed to Adminstrator.

To Reproduce

  1. Go to Users > All Users
  2. Edit a random user and change their Role to - No role for this site -
  3. Update user
  4. On the front end, purchase a Subscription product (test with simple, $10/month sub) and complete checkout
  5. After the order is complete, the user is now an Administrator

Expected behavior

When purchasing a non-subscription product, the role is left as is. So signing up for a subscription should either be the same as that, or at minimum switch the role to Subscriber, but certainly not Administrator.

Actual behavior

User role is switched to Administrator with all the trappings.

Product impact

Additional context

Stumbled upon while looking for default features with which to block an existing user from making purchases. While this ultimately didn't work, the outcome was concerning.

james-allan commented 1 year ago

Hi @jacoswan.

I haven't been able to replicate this issue. When I change one of my user's role to 'No role for this site'

Screenshot 2023-07-07 at 3 19 03 pm

and I make a subscription purchase, the user's role is set to "Subscriber" not administrator

Screenshot 2023-07-07 at 3 21 52 pm

Could you double check your WooCommerce > Settings > Subscriptions to make sure you haven't inadvertently set the subscriber role to "Administrator".

Screenshot 2023-07-07 at 3 26 38 pm
jacoswan commented 1 year ago

Hi @james-allan, thanks for checking.

How embarrassing for me, that's exactly the reason 🤦🏻‍♂️ I can't explain how that would have happened (and more importantly, why I didn't check that before opening this issue).

Sorry for wasting your time.