Support » Plugin: Paid Memberships Pro » Bug report : Detecting Membership change, incorrect placement of hook

  • I am trying to identify the change of membership plans using the hooks provided in the plugin.
    The hooks are :
    pmpro_before_change_membership_level
    pmpro_after_change_membership_level
    both the above hooks use the selected Level_id and user_id triggering it.

    However, it seems that the “before” hook do not return the correct existing level.
    So, even if I try using the function pmpro_getMembershipLevelsForUser it will always return blank.

    On further inspection I found that the update query runs before the “pmpro_before_change_membership_level” hook is called which leads to this result.

    refer screenshot : http://prntscr.com/bga9n4

    Please correct me if I am wrong. All I am trying to find is when a user triggers a membership change which two “action hooks” should I use to detect before and after states of the membership.

    https://wordpress.org/plugins/paid-memberships-pro/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi,

    If you could help me understand the purpose of using the two hooks (as in, what are you trying to do with the level information, and where are you using the pmpro_changeMembershipLevel() function which triggers them), I may be able to propose a way to achieve what you’re trying to do.

    The pmpro_changeMembershipLevel() function knows what to do with 3 different versions of the $level variable:

    The membership level object in the form of an array(),
    an integer (the presumed level ID), or
    null (set whatever level the specified or current_user has to false).

    For the ID (#) of the level, when passing it to the pmpro_changeMembershipLevel() from the checkout process, we use membership_id for the level id.

    If you’re wanting to use the actions in the context of the checkout page, it may be more appropriate to use the pmpro_checkout_before_change_membership_level action and the pmpro_after_checkout actions?

    Ok, I will try to explain the scenario, I am using PMPRo membership for a custom functionality where I attach a custom objects with Membership Level IDs. It is multi to multi relationship.
    Now, when a user changes his membership, I need to remove only the unchanged objects as every object also has a state associated with it which I do not want to change.

    The checkout hooks work good except they will not work when admin changes the membership from WP Admin panel or when the user membership Expires OR any other PMPro add on affect the membership status of a user.

    Correction in previous reply :
    I need to remove only the unchanged objects
    should be
    I need to remove only the changed objects

    Any progress on this ? This is a very big issue in Paid Memberships Pro, as the hook is clearly incapable of getting old membership levels. The old membership levels give the new membership level and hence makes the hook useless for anyone to use.

    Please I beg the authors to check the screenshot : http://prntscr.com/bga9n4

    Unfortunately, we will have to start recommending other membership plugins because the response on this issue have been dismal.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Bug report : Detecting Membership change, incorrect placement of hook’ is closed to new replies.