Function similar to update_post_meta for MetaBox.io custom table plugin

Support MB Custom Table Function similar to update_post_meta for MetaBox.io custom table plugin

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #8100
    jcleavelandjcleaveland
    Participant

    Hi,

    I am using the custom tables plugin to save post_meta to a custom table. I use taxonomies extensively to categorize data and make it easy to sort on the front-end. I have written a function that will write the taxonomy names to a comma separated string in a text meta field for use in an outside reporting platform.

    That function:

    function obh_update_member_meta_w_tax() {
       $member_needs_tags = get_the_terms( $post->ID, 'obh_member_needs_tags' );
        if ( $member_needs_tags && ! is_wp_error( $member_needs_tags ) ) {
                    
            $needs_tags = array();
            foreach ($member_needs_tags as $member_needs_tag) {
                $needs_tag[] = $member_needs_tag->name;
            }
                    
            $needs_tags = join( ", ", $needs_tag );
            update_post_meta( $post->ID, 'obh_needs_tags', $needs_tags );
        }
    add_action( 'save_post', 'obh_update_member_meta_w_tax' );

    When I update the post, the comma separated string saves to the post_meta table instead of the custom table.

    Is there a MetaBox.io function equivalent to update_post_meta that will work to save the data to the custom table? Or, am I best to use $wpdb->insert?

    Thanks!

    #8106
    Anh TranAnh Tran
    Keymaster

    We don't have such function yet. Please use $wpdb->insert. It's short and fast.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Function similar to update_post_meta for MetaBox.io custom table plugin’ is closed to new replies.