Git Product home page Git Product logo

Comments (3)

jtsternberg avatar jtsternberg commented on June 26, 2024 2

I just added a snippet that demonstrates deregistering/re-registering a field to replace an existing one: https://github.com/CMB2/CMB2-Snippet-Library/blob/master/filters-and-actions/cmb2_init_%24cmb_id-replace-field.php

However, you can simply replace attributes for an existing field as well: https://github.com/CMB2/CMB2-Snippet-Library/blob/master/filters-and-actions/cmb2_init_before_hookup-add-fields.php#L10-L14

from cmb2-snippet-library.

tw2113 avatar tw2113 commented on June 26, 2024 1

As long as you're matching up the meta key, you should be able to save content to the same spot regardless of plugin being used.

For example, the default metabox for custom fields from WP core. Say I create a post and save some fields as _my_meta_field. Then I load up and create a field in CMB2, and specify the field ID to be _my_meta_field. Once I go in to edit that post, the values previously saved would already be filled in to the new CMB2 fields.

I could also edit the same meta field from PHP or some sort of import, and it'd all just take.

The reason I say all this, is that it doesn't necessarily matter how the value is provided, as long as the value saved to the same matching spot. That said though, it depends also on the structure of of the saved data. Simple strings are no issues at all. If one method saves the data as a serialized array, and a different one saves as a string, you'll need to do some type checking and whatnot when it comes time to output to the frontend. Array to string errors aren't always fun :D

from cmb2-snippet-library.

pgroot91 avatar pgroot91 commented on June 26, 2024

Thanks guys for the responses 👍

@jtsternberg the example you provided on first sight looks like exactly what i need!

from cmb2-snippet-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.