⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

inserting custom variable to database



xcoder
  • profile picture
  • Member

Posted 30 May 2012 - 15:09 PM

say I have variable $x that fetches its data from the generated fields...how do i then insert the value back to the database?

kenvogt
  • profile picture
  • Member

Posted 30 May 2012 - 15:42 PM

Use callback_before_insert() and/or callback_before_update(). (The links give examples.)

xcoder
  • profile picture
  • Member

Posted 31 May 2012 - 06:56 AM

thanks but how do I add a new element to the $post array to be updated to the database?

xcoder
  • profile picture
  • Member

Posted 31 May 2012 - 08:15 AM

Thanks I finally fixed everything

kenvogt
  • profile picture
  • Member

Posted 31 May 2012 - 18:55 PM

The way to do it is to:[list=1]
[*]include the column you want posted with fields(), add_fields(), and/or edit_fields();
[*]use change_field_type() to make the column hidden;
[*]use callback_before_insert() and/or callback_before_update() to set your column value.
[/list]