Home ACF field is not being updated when hooking on to 'updated_user_meta'
Reply: 0

ACF field is not being updated when hooking on to 'updated_user_meta'

user1116
1#
user1116 Published in April 23, 2018, 9:17 am

I have 2 ACF fields created for the user in Wordpress site, lets call them 'field_one' and 'field_two'.

If i go to user profile, edit 'field_one' and hit 'update profile'. I need the value for 'field_two' to change. So, what i did was the following

function my_update_user_meta($meta_id, $object_id, $meta_key, $_meta_value) {
    if( $meta_key == 'field_one' ) {
        update_field('field_two', 'change value to this text', 'user_1');
    }
}

add_action( 'updated_user_meta', 'my_update_user_meta', 10, 4 );

However this does not work?!

What is strange is that if i listen to changes in a field that comes AFTER the field whose value i will need to change, it does work! For example this works:

function my_update_user_meta($meta_id, $object_id, $meta_key, $_meta_value) {
    if( $meta_key == 'field_two' ) {
        update_field('field_one', 'change value to this text', 'user_1');
    }
}

add_action( 'updated_user_meta', 'my_update_user_meta', 10, 4 );

Can somebody please explain why is this happening.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.526829 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO