Membership Plugin

WordPress Membership Plugin

  • Home
  • Documentation
  • Addons
  • Support
    • Quick Setup
    • Documentation
    • Premium Addon Support
    • Paid Support
    • Support Forum
    • Support Forum Search
    • Forum Login
    • Forum Registration
  • Contact

[Resolved] PPCP renewals saved with empty member_id (4.7.2 fallback has no effect)

Simple Membership Plugin › Forums › Simple Membership Plugin › PPCP renewals saved with empty member_id (4.7.2 fallback has no effect)

  • This topic has 1 reply, 2 voices, and was last updated 1 month ago by admin.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • October 16, 2026 at 10:43 am #32383
    freetiermorioka555
    Participant

    ## Summary

    When a PayPal PPCP subscription is started by a visitor who is not logged in, the button’s custom field contains no swpm_id. Every later PAYMENT.SALE.COMPLETED webhook then reuses that stored custom value, so each recurring payment is saved in the payments table with an empty member_id. I noticed that 4.7.2 adds a fallback for this, and I think it is very close to working. Below I describe why it cannot take effect yet, and a few ways it could be completed.

    ## Environment

    – Plugin: Simple Membership
    – Versions checked: 4.4.3 (in production) and 4.7.2 (source reviewed)
    – Gateway: PayPal, PPCP subscriptions (button type pp_subscription_new), REST webhooks

    ## What happens

    1. The payment button adds swpm_id to the custom field only if the visitor is logged in at the time the button is rendered.
    2. If a visitor subscribes while logged out, the custom field has no swpm_id. For an existing member, swpm_handle_subsc_signup_stand_alone() identifies the member by the payer email and updates the account correctly. So the member account itself is fine and does not end up incomplete.
    3. That custom string is stored in the swpm_transactions CPT. Every later PAYMENT.SALE.COMPLETED event reads it back through get_original_custom_value_from_transactions_cpt(). As far as I can tell, nothing in the plugin updates that stored value afterwards.
    4. As a result, save_txn_record() writes a payment row with an empty member_id for every payment, for as long as the subscription continues.

    ## Why the 4.7.2 fallback does not take effect

    4.7.2 adds a fallback in save_txn_record():

    `php
    // classes/class.swpm-transactions.php (4.7.2, lines 31-35)
    $txn_data[‘member_id’] = isset ( $custom_var[‘swpm_id’] ) ? $custom_var[‘swpm_id’] : ”;
    if( empty( $txn_data[‘member_id’] ) ){
    $txn_data[‘member_id’] = isset ( $ipn_data[‘member_id’] ) ? $ipn_data[‘member_id’] : ”;
    }
    `

    The value is also set on the other side:

    `php
    // ipn/swpm_handle_subsc_ipn.php (4.7.2, line 513)
    $ipn_data[‘member_id’] = $swpm_id;
    `

    However, that function receives $ipn_data by value:

    `php
    // ipn/swpm_handle_subsc_ipn.php (4.7.2, line 491)
    function swpm_update_member_subscription_start_date_if_applicable( $ipn_data ) {
    `

    Because PHP passes arrays by value, the assignment inside the function does not reach the caller. The PayPal webhook handler also does not use a return value:

    `php
    // lib/paypal/class-swpm-paypal-webhook-event-handler.php (4.7.2, lines 192-195)
    swpm_update_member_subscription_start_date_if_applicable( $ipn_data );
    …
    SwpmTransactions::save_txn_record( $ipn_data, array() );
    `

    So when save_txn_record() runs, $ipn_data['member_id'] is still unset, and recurring payments for PPCP subscriptions continue to be saved with an empty member_id. I may be reading this wrong, but this is what the 4.7.2 source suggests.

    For reference, the admin payments list already has a similar fallback. When member_id is empty, it looks the member up from subscr_id (classes/admin-includes/class.swpm-payments-list-table.php, around line 57). The same idea could be applied on the save side.

    ## Why this matters

    Because the payment rows are not linked to a member in the database, anything that relies on member_id (lookups, reports, aggregation) misses them. In practice, we have to link these payments by hand after receiving support requests.

    ## Suggested fix

    Any one of these should be enough:

    – Make swpm_update_member_subscription_start_date_if_applicable() take $ipn_data by reference (&$ipn_data), or have it return the modified array and use that in the caller.
    – Alternatively, as a last resort in save_txn_record(), look the member up from subscr_id. The function already calls SwpmMemberUtils::get_user_by_subsriber_id( $subscr_id ) a few lines later (for extra_info), so the lookup logic already exists.
    – Once the member is known, update the custom value stored in the swpm_transactions CPT, so that all later recurring payments are handled correctly automatically.
    – If a subscr_id fallback is added, it may need to handle the case where several member records share the same subscr_id. In our environment we have seen a small number of such duplicates.

    Thank you for your work on the plugin and for the 4.7.2 improvement in this area. Happy to share sanitized log excerpts if useful.

    October 17, 2026 at 6:54 am #32389
    admin
    Keymaster

    Thank you. I will look into it and apply a fix.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

Please read this message before using our plugin.

Search

Featured Addons and Extensions

  • Membership Form Builder Addon
  • Member Directory Listing Addon
  • WooCommerce Payment Integration
  • Member Data Exporter Addon

Documentation

  • Documentation Index Page

Copyright © 2026 | Simple Membership Plugin | Privacy Policy