• Resolved mvega3

    (@mvega3)


    Hello,

    Currently considering switching from ACF to Carbon Fields – I’m liking the plugin a lot so far.

    One question. ACF has an update_field function that allows for a post meta field to be quickly updated from anywhere in your theme/plugin. Looking through the Carbon Fields plugin, I don’t seem to find any equivalent – though my PHP skills are still quite amateur, so it’s possible I overlooked something obvious. What would be the best way of approaching my problem?

    For reference, I’m attempting to port over a project from ACF which involved generating a unique key from Gravity Forms and saving it as post meta information. The field is a simple number field, but the data needs to come from Gravity Forms and not the user, so having the fields editable via WordPress Post Editor isn’t too helpful.

    Thanks again! I hope to contribute once my programming skills are not quite as pitiable as they are at present.

    Mario

Viewing 1 replies (of 1 total)
  • Plugin Author htmlBurger

    (@htmlburger)

    Hey Mario,

    Thanks for the kind words, we are glad that you like the plugin!

    We don’t have a dedicated update function (yet!), but the storage technique of Carbon Fields is not very complicated. In your situation you can just do a post meta update, for example:

    If your field declaration is

    
    Container::make( 'post_meta', __( 'Post Settings', 'crb' ) )
        ->add_fields( array(
            Field::make( 'text', 'crb_unique_key' ),
        ));
    

    The post meta key that will be stored in the database will be _crb_unique_key, so you can update it using

    
    update_post_meta( $post_id, '_crb_unique_key', 'my unique key generated by gravity forms' );
    

    Hope this helps. If you have further questions don’t hesitate to ask.

    Cheers!

Viewing 1 replies (of 1 total)
  • The topic ‘Updating fields with PHP functions?’ is closed to new replies.