Thread Starter
Frumph
(@frumph)
basically registered users in a paid membership couldn’t see protected content
— solved —
Bad logic in the ms_has_membership() and associated functions that check for if the user is in an appropriate membership continues to return a value of false.
This makes it so people in memberships cannot see protected content because of bad logic gate.
Because of this bad logic, the horribly not-so-intuitive controls of the protection rules needed to be adjusted.
Without having a ‘visitor’ membership that includes not-logged-in users and logged in users that are not in any other memberships no matter what you do it returns false.
—————–
So – a default visitors membership should be added to the code base to solve this for everyone else who also updated from old membership that didn’t have a ‘default’, and even then the ‘default’ needs to include logic for logged in users that are not in any other memberships.
— NOTE: This made the capabilities add-on also fail it’s logic
Added fix for (my) usage for having paid memberships become contributors and then back down again if they are not paid. (if anyone is so inclined to want an example of how-to switch from subscriber to contributor based on a certain membership – adjust membership # and roles to what your needs are.
if (function_exists('ms_has_membership')) {
$current_user = wp_get_current_user();
if ($current_user->ID) {
if ( ms_has_membership(18017) ) {
if (in_array( 'subscriber', (array)$current_user->roles )) {
$current_user->remove_role('subscriber');
$current_user->add_role('contributor');
}
} elseif (in_array( 'contributor', (array)$current_user->roles)) {
$current_user->remove_role('contributor');
$current_user->add_role('subscriber');
}
}
}
-
This reply was modified 8 years, 4 months ago by
Frumph. Reason: fixed [code] to `
-
This reply was modified 8 years, 4 months ago by
Frumph.
Thread Starter
Frumph
(@frumph)

Here is an image showing the extra membership – this membership [member] does *not* exist in membership 2 and so it’s still seeing it AND using it for peoples ms_has_membership() which causes protected content to fail being seen.
— Also note the additional bug of the start date and end date’s are all the day that they were imported and *not* the proper ones they are supposed to be.
-
This reply was modified 8 years, 4 months ago by
Frumph.
Thank you for the feedback and fix. I will pass this along to our developers.