Home › Forums › ACF PRO › Keep user Description meta value synched to ACF field › Reply To: Keep user Description meta value synched to ACF field
Actually found a solution, using the save_post filter.
// SYNC USER META DATA
add_filter('acf/save_post', 'acf_set_user_meta_description', 20, 1);
// FUNCTIONS
function acf_set_user_meta_description( $user_id ){
// Keep User meta 'description' in sync with our ACF field
$bio = get_field('user_bio', $user_id);
// $user_id is actually user_{id}. To update WP, we remove the "user_" part.
$user_id = (int)substr(strrchr($user_id, "_"), 1);
if(!empty($user_id)){
// Will return false if the previous value is the same as $new_value.
$updated = update_user_meta( $user_id, 'description', $bio );
}
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.