Support

Account

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 );
    	}
    }