strangerstudios / pmpro-roles

Adds a custom WordPress Role for each membership level in Paid Memberships Pro
https://www.paidmembershipspro.com/add-ons/pmpro-roles/
GNU General Public License v2.0
17 stars 16 forks source link

Fixed issue where level role settings weren't being honored sometimes… #28

Closed ideadude closed 3 years ago

ideadude commented 3 years ago

Users of PMPro 2.5.8 or higher (where the pmpro_after_all_membership_level_changes hook was being used) sometimes wouldn't get the role they were supposed to.

The after_all_level_changes method was looking for a level's role in the wp_options table, but sometimes there might not be an option there for a level. However, when you edited the level, the default role level was chosen.

This update introduces a get_roles_for_level method that will pull the roles from options, or if they aren't present there, default to the role for the level.

There is talk about changing the default behavior to use the WP default role instead of the role for the level as the default when no setting is present, but this PR does not address that. We should consider that further, especially before merging this functionality into PMPro core if we do that.