Guest User

Untitled

a guest
Nov 14th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. value_1 = red blue; value_2 = gold silver;
  2.  
  3. merged_values = red blue gold silver;
  4.  
  5. // This function runs after your post is saved
  6. function my_acf_save_post( $post_id ) {
  7.  
  8. // Get new value of field 1 and remove ;
  9. $value1 = str_replace( ';', '', get_field( 'field1', $post_id ) );
  10.  
  11. // Get new value of field 2 and remove ;
  12. $value2 = str_replace( ';', '', get_field( 'field2', $post_id ) );
  13.  
  14. // Merged values with ; on the end
  15. $merge = $value1.' '.$value2.';';
  16.  
  17. // Update field 3 with the new value which should be
  18. // value1 value2;
  19. update_field( 'field3', $merge, $post_id );
  20. }
  21. add_action('acf/save_post', 'my_acf_save_post', 20);
Add Comment
Please, Sign In to add comment