WordPress.org

Forums

BuddyPress Docs
save new fields in database (2 posts)

  1. laurahreniucu
    Member
    Posted 1 year ago #

    Hello.

    I have added extra fields to complete when creating a doc. I added them in DB and on the doc creating/editing pages.

    The question is: how do I get the info to be added in database? Where is the code for that? I really can't seem to find it.

    Thank you.

    http://wordpress.org/plugins/buddypress-docs/

  2. laurahreniucu
    Member
    Posted 1 year ago #

    I found the "save" function in query-builder.php . But I couldn't find any way to get the info inserted in the new docs form into the database.

    I found:

    $defaults = array(
    				'post_type'    => $this->post_type_name,
    				'post_title'   => $_POST['doc']['title'],
    				'post_name'    => isset( $_POST['doc']['permalink'] ) ? sanitize_title( $_POST['doc']['permalink'] ) : sanitize_title( $_POST['doc']['title'] ),
    				'post_content' => sanitize_post_field( 'post_content', $doc_content, 0, 'db' ),
    				'post_status'  => 'publish'
    			);

    But when i edit this "defaults" to add more fields it doesn't do anything. My try:

    $defaults = array(
    				'post_type'    => $this->post_type_name,
    				'post_title'   => $_POST['doc']['title'],
    				'nr_data_contract' => $_POST['nr_data_contract'],
    				'nr_data_fisa' => $_POST['nr_data_fisa'],
    				'post_name'    => isset( $_POST['doc']['permalink'] ) ? sanitize_title( $_POST['doc']['permalink'] ) : sanitize_title( $_POST['doc']['title'] ),
    				'post_content' => sanitize_post_field( 'post_content', $doc_content, 0, 'db' ),
    				'post_status'  => 'publish'
    			);

    "nr_data_contract" and "nr_data_fisa" are the ids of the new fields in the docs creation page.
    Is there something else i have to do to get the data in the database?

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • BuddyPress Docs
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.