I am trying to:
solution proposed here:
https://toolset.com/forums/topic/custom-field-is-updated-incorrectly-before-payment-completion/?bbp_reply_to=2678584&_wpnonce=e351045480#new-post
I expected to see:
after replacement hook to 'cred_commerce_after_payment_completed'
the field should be updated after payment completed
Instead, I got: it still updated before payment.
Hi,
I tried to log in to the website's admin area, but it seems to have some hidden/private link for that.
For deeper troubleshooting, I'll need to know the exact steps that you took for this testing, along with the details of the code changes that were made.
(I'll also need your permission to download the clone/snapshot of the website, in case it needs to be investigated on a different server)
Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.
regards,
Waqar
Thank you for sharing these details and I was able to access the admin area.
I'll need to perform some tests on my website with a similar setup and code. Will share the findings, as soon as this testing completes.
Thank you for your patience.
Just wanted to let you know that I'm still working on this and will share the findings with you today.
Thank you for waiting, as this troubleshooting turned out to be more complicated than initially expected.
I found that the following function existed in the active theme's 'functions.php' file:
add_action('cred_save_data', 'plus_one_shagchm',10,2);
function plus_one_shagchm ($post_id, $form_data)
{
// Execute for form ID: 123
if ($form_data['id'] == 15672 or 16322 ) {
......
}
}
However, how this function checks for the submission of specific forms is incorrect. As a result, it is executed for all the forms, not just those whose IDs are specified, and custom field values are updated in cases where they shouldn't.
The correct approach to checking for multiple specific forms is as follows:
add_action('cred_save_data', 'plus_one_shagchm',10,2);
function plus_one_shagchm ($post_id, $form_data)
{
// Execute for form IDs specified in the array
$target_forms = array( 15672 , 16322 );
if (in_array($form_data['id'], $target_forms)) {
......
}
}
I hope this helps and please let me know if you need further assistance.