Support

Account

Home Forums Backend Issues (wp-admin) Replacing custom post type post title with an acf? Reply To: Replacing custom post type post title with an acf?

  • Hi @Elliot!
    Thanks for the udate.
    I’ve tweaked the function some & found out that, for some reason, including $\POST in the function makes it work !
    Even if the $_POSRT does not contain the field ‘memeber_firstname per se…I guess the get_field function than can refer to the field name, with it’s corresponding value in the postmeta table :

    <?php
    function my_acf_update_value( $value, $post_id, $field ) {
    	global $_POST;
    	// vars
    
    	$new_title = get_field('member_firstname', $post_id) . ' ' . $value;
    	$new_slug = sanitize_title( $new_title );
    
    	// update post
    	// http://codex.wordpress.org/Function_Reference/wp_update_post
    	  $my_post = array(
          'ID'           => $post_id,
          'post_title' => $new_title,
    	  'post_name' => $new_slug
      );
    
    // Update the post into the database
      wp_update_post( $my_post );
    	
    	
    }
    
    add_filter('acf/update_value/name=member_lastname', 'my_acf_update_value', 10, 3);
    
    ?>

    Thanks for all !
    I intend to post a full & clear how-to post on this solution as it may come in handy to anyone else.Obviously won’t take the credit for any of it ! 🙂

    Thanks again
    JMB