Support

Account

Home Forums ACF PRO Auto populate custom field with user data Reply To: Auto populate custom field with user data

  • I actually take that back on the second bit of code. Since the field does not exist yet you must use the field key

    
    add_action('acf/save_post', 'update_name_provider_field');
    function update_name_provider_field($post_id) {
      if (is_admin()) {
        // don't run in admin
        return;
      }
      if (get_post_type($post_id) != 'YOUR CUSTOM POST TYPE')) {
        // don't run if not your post type
        return;
      }
      // use the acf field key here
      update_field('field_01234567', get_current_user_id(), $post_id);
    }