-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Payment meta not being stored in 2.0+ #2675
Comments
I noticed something in class-give-db-meta.php that has me wondering if prefixing tables with something other than wp is a potential problem. This is on line 288: Is that a hard-coded assumption that give_paymentmeta is prefixed with wp_? |
@slewisma Thank you for catching that. I added a fix to core and we are testing it. Soon we release a minor release if this is fixed. 9e7bbe3 If possible can you download new file and test it on your staging or local site: https://github.com/WordImpress/Give/tree/master |
I tested the db prefix change and it did not resolve the issue with the custom field content not being written to the database but it didn't break anything else and is still probably an important fix for other reasons. So the main bug reported in this issue still stands but I'd keep the prefix correction in core anyway. |
@slewisma I did not get actual issue because of your second comment. I added a new fix please review it now. For ref:8d52b46 |
@slewisma It is working as expected. |
Issue Overview
Custom fields that used the give_payment_meta filter to store their values in the payment_meta array do not get saved at all in 2.0. Existing data does migrate to the payment_meta table in the upgrade process but the same form doesn't save data after the upgrade.
Expected Behavior
I expect code like this to add a walker's name to the _give_payment_meta array in the payment_meta table post 2.0 upgrade:
`add_action( 'give_before_donation_levels', 'give_gfw_custom_form_fields', 10, 1 );
function give_gfw_custom_form_fields( $form_id ) {
?>
Walker or team to credit your donation to (leave blank for general donations):', 'give' ); ?>
<?php
}
add_filter( 'give_payment_meta', 'give_gfw_store_custom_fields' );
function give_gfw_store_custom_fields( $payment_meta ) {
$payment_meta['walker'] = isset( $_POST['give_walker'] ) ? implode( "n", array_map( 'sanitize_text_field', explode( "n", $_POST['give_walker'] ) ) ) : 'None';
return $payment_meta;
}
`
This code is directly based on Give Developer documentation examples. I have about 10 more sites depending on similar code and cannot upgrade any of them to 2.0 until this is fixed.
As an aside, custom fields added this way have never been accessible in the basic export tool or the CSV toolbox. I end up having to write my own export tools for customers. The export tool(s) only look for top-level meta fields, not fields in the _give_payment_meta array. I can open a separate issue on this if needed.
Current Behavior
The record for the donation is created and standard meta data is stored in the give_payment_meta table but the custom field is not stored anywhere.
Possible Solution
If there is a change in how developers should store custom fields starting in 2.0, please tell us. It won't be fun rewriting the customizations for every customer but it is better than either breaking their functionality or not being able to upgrade. Obviously, if this is the case, developer documentation needs to be modified and a note should probably go in the changelog.
If this is a bug and can be fixed, I'd be much happier.
Steps to Reproduce (for bugs)
You can use the above filter and action then examine the give_payment_meta table with phpmyadmin or similar to see that there is no _give_payment_meta array stored in the donation record.
The site I tested this on is https://gfwalk.org/donate but I cannot give access to the backend nor the database there since it has live donor data in it from past year's walks.
Related Issues and/or PRs
Todos
WordPress Environment
Home URL: https://gfwalk.org
Site URL: https://gfwalk.org
WP Version: 4.9.2
WP Multisite: –
WP Memory Limit: 512 MB
WP Debug Mode: –
WP Cron: ✔
Language: en_US
Permalink Structure: /%postname%/
Show on Front: page
Page on Front: Home (#701)
Page for Posts: News (#703)
Table Prefix Length: 4
Table Prefix Status: Acceptable
Admin AJAX: Accessible
Registered Post Statuses: publish, future, draft, pending, private, trash, auto-draft, inherit, refunded, failed, revoked, cancelled, abandoned, processing, preapproval
Server Environment
Hosting Provider: DBH: localhost, SRV: gfwalk.org
TLS Connection: Connection uses TLS 1.2
TLS Connection: Bad
Server Info: Apache
PHP Version: 7.0.22
PHP Post Max Size: 128 MB
PHP Time Limit: 30
PHP Max Input Vars: 4000
PHP Max Upload Size: 128 MB
cURL Version: 7.45.0, OpenSSL/1.0.1e
SUHOSIN Installed: –
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
SoapClient: ✔
DOMDocument: ✔
gzip: ✔
GD Graphics Library: ✔
Multibyte String: ✔
Remote Post: ✔
Remote Get: ✔
Give Configuration
Give Version: 2.0.0
Give Cache: Enabled
Database Updates: All DB Updates Completed.
Give Cache: Enabled
Give Cache: ✔New Donation✔Donation Receipt✔New Offline Donation✔Offline Donation Instructions✔New User Registration✔User Registration Information❌Email access
Upgraded From: –
Test Mode: Disabled
Currency Code: USD
Currency Position: After
Decimal Separator: .
Thousands Separator: ,
Success Page: https://gfwalk.org/donation-confirmation/
Failure Page: https://gfwalk.org/transaction-failed/
Donation History Page: https://gfwalk.org/donation-history/
Give Forms Slug: /donations/
Enabled Payment Gateways: Offline Donations, PayPal Standard, Test Donation
Default Payment Gateway: PayPal Standard
PayPal IPN Verification: Disabled
PayPal IPN Notifications: N/A
Donor Email Access: Disabled
Session Configuration
Give Use Sessions: Enabled
Session: Disabled
Active Give Add-ons
Other Active Plugins
ManageWP - Worker: by ManageWP – 4.3.3
Responsive Lightbox: by dFactory – 1.7.2
Toolset CRED: by OnTheGoSystems – 1.9.4
Toolset Types: by OnTheGoSystems – 2.2.21
Toolset Views: by OnTheGoSystems – 2.5.2
Trail Websites Give Enhancments: by Scott Lewis – 1.0
Wordfence Security: by Wordfence – 6.3.22
WP Mail SMTP: by WPForms – 1.2.2
Inactive Plugins
Active MU Plugins
ManageWP - Worker Loader: by ManageWP –
Theme
Name: GF Walk
Version: 1.0
Author URL: http://slewis.org
Child Theme: Yes
Parent Theme Name: Toolset Starter
Parent Theme Version: 1.4.2
Parent Theme Author URL: http://www.onthegosystems.com/
The text was updated successfully, but these errors were encountered: