Skip Navigation

[Resolved] Trying to programmatically change a field value

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by jamesA-6 1 year, 3 months ago.

Assisted by: Waqar.


Tell us what you are trying to do?
On checkout of a certain product type (tied to Toolset Commerce) I want to change the value of the Payment Status toolset custom field.

Is there any documentation that you are following?
I have this function in place and I wonder if it immediately obvious why my field value is not being changed?

function payment_complete( $order_id, $old_status, $new_status ){
if( $new_status == "completed" ) {

$user_id = get_current_user_id();

'post_type' => 'song-contest-entry',
'post_status' => 'publish',
'posts_per_page' => 1,
'author' => $user_id

$current_user_posts = new WP_Query ( $args );

if ( $current_user_posts->have_posts() ) {

while ( $current_user_posts->have_posts() ) { $current_user_posts->the_post();

$payment_status = get_post_meta(get_the_ID(), 'wpcf-paymentstatus', true);

if ($payment_status == 'Unpaid') {

update_post_meta( $post_id, 'wpcf-paymentstatus', 'Paid' );





add_action( 'woocommerce_order_status_changed', 'payment_complete', 99, 3 );

Is there a similar example that we can see?
Not that I am aware of.

What is the link to your site?



Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)


Thank you for contacting us and I'd be happy to assist.

The steps and the logic used in your custom function seem correct.

If the custom field value is not updated when the order status is changed to 'completed', I recommend performing line-by-line debugging to see which part of the code is working and which isn't.

You'll find some useful information on using the debugging error log for such troubleshooting:

I hope this helps and please let me know if you need any further assistance around this.



My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.