Custom post type not saved in the new custom table

Support MB Custom Table Custom post type not saved in the new custom tableResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #15606
    JeanROUSTANJeanROUSTAN
    Participant

    Hi,
    i've successfully created a new custom table named 'collaborateur_table' with some fields.
    I've a custom post type named 'collaborateur' with fields created like that :

    function get_meta_box_collaborateur( $meta_boxes ) {
            $meta_boxes[]= array(
            'id' =>   'creation_collaborateur',
            'title' => esc_html__( 'Fiche collaborateur', 'textdomain' ),
            'post_types' => array( 'collaborateur' ),
            'context' => 'advanced',
            'priority' => 'default',
            'autosave' => false,
            'storage_type' => 'custom_table',    
            'table'        => 'collaborateur_table', // my custom table name
            'fields' => array(
    array(
                    'id' => 'title',
                    'type' => 'text',
                    'name' => esc_html__( 'title', 'textdomain' ),
                    ),
    array(
                    'id' => 'nom',
                    'type' => 'text',
                    'name' => esc_html__( 'Nom', 'textdomain' ),
                    ),
    [ etc...]
             ),
    
        );
    
        return  $meta_boxes;
    }
    add_filter( 'rwmb_meta_boxes', 'get_meta_box_collaborateur' );

    Everything is correctly displayed
    But when i publish a new post type 'collaborateur', only the title is registered in the wp_posts table. No new entries is registered in my custom_table.
    Did I forget something to be able to save my custom fields in my new table ?

    #15607
    JeanROUSTANJeanROUSTAN
    Participant

    I've forgotten, my custom fields are not saved too. When I re-edit my new post type, only the title is registered

    #15608
    JeanROUSTANJeanROUSTAN
    Participant

    Sorry for the inconvenience, I just found my mistake.
    The fields in my table were different from the fields. I left the prefix ...
    i fixed that and now all is working fine 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.