Title: Saving data to sql database
Last modified: March 26, 2019

---

# Saving data to sql database

 *  Resolved [kandysoft](https://wordpress.org/support/users/kandysoft/)
 * (@kandysoft)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/saving-data-to-sql-database/)
 * Hi,
 * I have a webapp that is using WP as a framework, but all data is stored in separate
   database tables (not linked to posts/metadata/comments etc).
 * CMB2 worked great for my settings dialog on the frontend already, but I would
   need to create another dialog with dynamic field population (no problem with 
   that) which will save the field contents to my own table, not as metadata.
    Is
   there a way to replace the default “Save” button functinality and replace it 
   with my own PHP code to save the entered field data to the database?
 * Thank you
    Kerry.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [7 years, 2 months ago](https://wordpress.org/support/topic/saving-data-to-sql-database/#post-11357400)
 * Slightly long, but I would check out [https://wordpress.org/support/topic/set-field-values-from-database-table-but-not-metadata/](https://wordpress.org/support/topic/set-field-values-from-database-table-but-not-metadata/)
   which is a recent forum post on the exact same topic as saving to your own custom
   location. If you still have questions afterwards, or perhaps need a little help
   adapting some of the code, you can post all that back here and we’ll see what
   we can do to help.
 *  [dkurth](https://wordpress.org/support/users/dkurth/)
 * (@dkurth)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/saving-data-to-sql-database/#post-11358126)
 * yes…see my gist. I am doing exactly this.
 * [https://gist.github.com/dskurth/d56744de4ae076c417f59b2a459eaf4b](https://gist.github.com/dskurth/d56744de4ae076c417f59b2a459eaf4b)
 * The key is to get and stuff the fields directly . I work with a custom table 
   on both the back end and the same table on the front end with users.
 *  Thread Starter [kandysoft](https://wordpress.org/support/users/kandysoft/)
 * (@kandysoft)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/saving-data-to-sql-database/#post-11360928)
 * Hi [@dkurth](https://wordpress.org/support/users/dkurth/) ,
 * Thanks alot for the example. I managed to get it to work, although I’d prefer
   a “all fields in one line” layout for one record.
 * I’ll check how to do that with an own field type. Should be workable.
 * Cheers
    Kerry.
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [7 years, 2 months ago](https://wordpress.org/support/topic/saving-data-to-sql-database/#post-11361919)
 * You could always serialize the incoming data right before the writing to your
   field, much like how the wp_options table does for complex data.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Saving data to sql database’ is closed to new replies.

 * ![](https://ps.w.org/cmb2/assets/icon.svg?rev=2866672)
 * [CMB2](https://wordpress.org/plugins/cmb2/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cmb2/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cmb2/)
 * [Active Topics](https://wordpress.org/support/plugin/cmb2/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cmb2/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cmb2/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [7 years, 2 months ago](https://wordpress.org/support/topic/saving-data-to-sql-database/#post-11361919)
 * Status: resolved