strangerstudios / paid-memberships-pro

WordPress membership plugin to restrict access to content and charge recurring subscriptions using Stripe, PayPal, and more. Fully open source. 100% GPL.
https://www.paidmembershipspro.com
Other
457 stars 357 forks source link

User fields are not being saved during checkout for PayPal Standard #2597

Open andrewlkho opened 1 year ago

andrewlkho commented 1 year ago

Describe the bug Custom user fields created either using the admin interface or in code are displayed correctly on the membership sign-up page. However, these do not get saved to the database in the wp_usermeta table. I suspect that this is to do with the PayPal Standard gateway which is being used on the site in question.

To Reproduce Steps to reproduce the behavior:

  1. Instal Paid Memberships Pro and use the PayPal Standard gateway
  2. Create a custom user field either in code or using the admin interface
  3. Attempt to sign up as a new user and checkout with Paypal
  4. Review the database for the custom user field

Expected behaviour The value of the submitted user field is saved in the wp_usermeta table.

Isolating the problem (mark completed items with an [x]):

WordPress Environment

andrewlkho commented 1 year ago

From my limited knowledge of Paid Memberships Pro, I suspect that this is due to how the PayPal Standard gateway workflow operates. It looks to me like:

  1. The pmpro_before_send_to_paypal_standard action runs the pmpro_after_checkout_save_fields function in includes/fields.php
  2. This checks if that field should be saved for the level being checked out by calling:
    if ( ! pmpro_check_field_for_level( $field, "profile", $user_id ) ) {
    continue;
    }
  3. pmpro_check_field_for_level with those arguments checks to see if the submitted field's specified levels are one that the $user_id holds.

In the case of the PayPal Standard workflow, as the pmpro_before_send_to_paypal_standard hook's name suggests, this is run before going to PayPal to checkout. Therefore, in step (3) it returns false because the field's allowed level's are not one that the current user ID holds, as the user has not yet checked out to acquire that level. Thus the field is not saved.

I have temporarily fixed this in my instance by changing the line in step 2 to:

if ( ! pmpro_check_field_for_level( $field, "default", $user_id ) ) {
    continue;

but I am unclear on other ramifications of this.

andrewlimaza commented 8 months ago

@andrewlkho Sorry to hear about this issue you are facing here. Are you still facing this issue? I am going to try and replicate this issue before updating this issue status.

If you are still facing issues, I recommend to use PayPal Express instead. The only additional information needed would be more merchant details but any PayPal account that supports Standard can use Express.

andrewlimaza commented 6 months ago

Thanks for your patience @andrewlkho, all this information helps. I was able to replicate this and it needs to be resolved. We do recommend PayPal Express over PayPal Standard - https://www.paidmembershipspro.com/read-using-paypal-standard-paid-memberships-pro/

However, we are going to look into a solution for this.

MaximilianoRicoTabo commented 3 months ago

this isn't reproducing for me in v3.0.4. User fields are stored just fine with paypal standard gateway @andrewlimaza

ipokkel commented 3 months ago

Received a report of textarea fields not saving when using PayPal Standard: #568735 (User resolved the issue by switching to PayPal Express)

ipokkel commented 3 months ago

User reported user fields are not saving when using PayPal Standard: #573404